XF 2.1 Backing Up XF

CrazyChef

Active member
I find it very odd that XF doesn't have an internal backup feature. Or am I missing something? Preferably to an external source, such as Backblaze.
 
It would only get used if someone's host didn't provide proper backup, I imagine. My site backs up automatically every morning and I have easy access to those backups. Also, an internal backup would not pick up other parts of the site, e.g. if you also run a WordPress site for blogging. An external, server/host backup will pick up everything so would still be the preferred solution. I, for instance, have two copies of my site (a live and a dev) each with its own db, so an external backup gets that all in one swoop.

That said, there is at least one add-on for doing backups of your databases.

 
We do it at the server level.

I set a CRON to do ours twice daily, and then we auto download it off site twice daily. (in addition to 2 or 3 other backups done by the ISP) It keeps a daily history backup that overwrites every 10 days. We have another that generates a tar and downloads that.
 
We do it at the server level.

I set a CRON to do ours twice daily, and then we auto download it off site twice daily. (in addition to 2 or 3 other backups done by the ISP) It keeps a daily history backup that overwrites every 10 days. We have another that generates a tar and downloads that.
I would like to do this, but am not familiar enough with the process to use it.
 
We do it at the server level.

I set a CRON to do ours twice daily, and then we auto download it off site twice daily. (in addition to 2 or 3 other backups done by the ISP) It keeps a daily history backup that overwrites every 10 days. We have another that generates a tar and downloads that.
Could you let me know how this is done?
 
Creating the backup can be as easy as adding a new cron job in the above screen you showed, to run at 2:55am (example) with something like:

(uncompressed)
mysqldump --opt --default-character-set=utf8mb4 -u'ADMINACCT' -p'PASSWORD' xenforo > /var/www/html/MYDOMAIN/mysql_backups/xenforo-backup-$(date +\%F).sql

(compressed)
mysqldump --opt --default-character-set=utf8mb4 -u'ADMINACCT' -p'PASSWORD' xenforo | gzip -c > /var/www/html/MYDOMAIN/mysql_backups/xenforo-backup-$(date +\%F).sql.gz

ADMINACCT = your admin login account name
PASSWORD = your admin password
MYDOMAIN = domain where database operates

or a fancier example for backup with short day of the week for 7 day rotation:
/bin/mysqldump --opt --default-character-set=utf8mb4 -u"MYSERVERUSERNAME-HERE" -p"MYSERVERPW-HERE" DATABASE_NAME > /home/ACCTNAME/back/xf-bkup-$(date +\%a).sql

This last one will store 7 backups on your server, named by the day of the week, so make sure you have room. You can put them in a folder not reachable from your website. (EX: BACK) If you want it off site, there are several ways. Some send it off to s3, some download it to a local linux server at home, some use an old windows program like FTPSYNCH go ftp in and grab it a few minutes after the cron runs daily.

You could also have it run a second cron to make a TAR file of the site contents, with something like:

tar -cf /home/ACCTNAME/back/xf_files.tar /home/ACCTNAME/public_html/

I hope this is useful, to get you started.
 
Top Bottom