Simple backup question...

click here

Active member
So I use mysqldump to backup my xenforo DB but that doesn't include the attachments, what's an easy way to backup the attachments?
 
I back up my attachments weekly to a locally attached hard drive, as an off-line safety backup. The hard drive is then continually cloud backed-up via Backblaze, as a secondary backup.

I use the following command (I'm on a Mac):

Code:
Remote sync command for attachments:

rsync -av --delete --rsh=ssh 'ADMINACCOUNT@DOMAIN.COM:/var/www/html/DOMAIN.COM/public_html/forums/internal_data/attachments' /Volumes/LOCALDRIVENAME/internal_data

ADMINACCOUNT is your admin account name that you would use to ssh into your server
DOMAIN.COM is the domain of your server
LOCALDRIVENAME is the name of your local attached hard drive

If you are using Windows, your syntax for local drive may differ moderately.

What this command does is compares the changed files (attachments) on the server to the local (stored) attachments on the hard drive, and syncs them up (normally, adding new attachments). This is only for the attachments (full-size photos/attachments), but you could do the same for the thumbnails and/or "data" folder.

With the script above, you have to manually enter the password at the ssh login prompt. I believe this step can be automated if you wanted it to, and the command could easily be added daily or however often you wanted as a cron job.

===========

For daily backup of my database, I use the following command:

Code:
mysqldump --opt --default-character-set=utf8mb4 -u'ADMINACCOUNT' -p'PASSWORD' xenforo | gzip -c > /var/www/html/DOMAIN.COM/mysql_backups/xenforo-backup-$(date +%F).sql.gz

This backs up the main database in a dated file, which is compressed and stored on the server. A cron job does this every morning. This gives me seven rolling backups -- one per day, with a different filename corresponding to that day of the week. Then I download one of the stored files once a week to my local hard drive, where it is cloud-backed-up via Backblaze for extra security.

I also have my hosting provider, Linode, run a full backup of my 80GB server (this is everything collectively -- forum, database, etc.) every morning at 4AM. This is a full restorable backup every day, with one snapshot stored from the previous week, and one additional snapshot stored from the previous month.
 
Last edited:
Top Bottom