Advertisement:

Author Topic: Best Way To Backup?  (Read 613 times)

Offline Paffman

  • Jr. Member
  • **
  • Posts: 134
  • Me & Randy Mamola - Donington 2007
Best Way To Backup?
« on: June 27, 2020, 09:25:10 PM »
Had a quick search and couldn't see an answer.

What is the best way to backup a forum/database?

In cpanel I am not able to download the forum folder. I am a little unsure how to use phpMyAdmin.

Please run it past me slowly :-)

Steve

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,298
  • Master of BBC Abuse
Re: Best Way To Backup?
« Reply #1 on: June 28, 2020, 01:11:35 AM »
Does your host allow cron jobs? Those are the most convenient for database backups (it's just a fancy name for a scheduled backup).

Backing up files can only be done by downloading them to off-server storage. You should be able to download files, either individually or as gzipped folders. If you can't, that suggests a problem with the host.

ETA: Added screenshot of cPanel, so you can see where cron jobs hide. :)

Offline Paffman

  • Jr. Member
  • **
  • Posts: 134
  • Me & Randy Mamola - Donington 2007
Re: Best Way To Backup?
« Reply #2 on: June 29, 2020, 08:41:07 AM »
Thanks for that, found it.

Is it just for Linux?

Get this warning: "Warning: You need to have a good knowledge of Linux commands before you can use cron jobs effectively. Check your script with your hosting administrator before adding a cron job."

Looks like there are PHP commands to use...

Don't know the commands to use.

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,298
  • Master of BBC Abuse
Re: Best Way To Backup?
« Reply #3 on: June 29, 2020, 06:29:44 PM »
Sounds scary, but the good news is if you get it wrong it won't kill the server. It just won't make backups for you.

Code: [Select]
mysqldump -u chief_muppet -pmybirthday db_forumstuffz | gzip > /home/muppet_show/backups/db_forumstuffz_$(date +\%Y\%m\%d).sql.gz
That will run a daily backup, date stamp it, gzip it, and stash it in a backups folder that is not web-accessible (you don't want the backups to be web-accessible, for obvious reasons).
Naturally, change "chief_muppet" to actual username and change "mybirthday" to your actual password, as well as changing "db_forumstuffz" to the real database name and "muppet_show" to your domain name.

I also run another one, which stops the backups folder overflowing by deleting any backups older than one week.

Code: [Select]
find /home/muppet_show/backups -mtime +6 -type f -delete
You can change +6 to whatever number you like, if you want to keep backups on the server for two weeks or whatever.