Any way to regurarly backup the xenForo database?

Marco Famà

Active member
Dear all

is there a function which I dont' see within the admin panel, that can let me choose to create a trigger for automatically backupping the xenForo instance, and receive such backup file via Email, maybe zipped?

I'm starting to be afraid of this matter, as my community is rapidly growing in contents..

Thanks a lot for your time,
Marco
 
I set up a crontab on my server to back everything up...

Code:
#!/bin/sh
 
# XenForo backup script
 
#set database connection info
db_username="username"
db_password="password"
db_name="database"
 
# set filenames
filename_sql="backup-db-"`eval date +%Y%m%d`".sql"
filename_sql_gz="backup-db-"`eval date +%Y%m%d`".gz"
filename_data="backup-data-folder.tar"
filename_data_gz="backup-data-folder.tar.gz"
 
# set path to backups and website directory without trailing slashes
backup_path="/path/to/backup/directory"
web_dir="/path/to/website/directory"
 
# dump the database
mysqldump -u$db_username -p$db_password $db_name > $backup_path/$filename_sql
 
# gzip the database at max compression to save space
gzip -9 $backup_path/$filename_sql
 
# if it's friday, we'll backup the website directory too
if [ $(date '+%a') == "Fri" ]; then
    # create a tarball of the web folder
    tar -cf $backup_path/$filename_data $web_dir/*
    # gzip the website directory
    gzip -f9 $backup_path/$filename_data
    # remove the tarball
    rm -f $backup_path/$filename_data
fi
 
# Log that the backup has been done
echo "Backup for `eval date +%d`/`eval date +%m`/`eval date +%Y` complete" >> $backup_dir/backup.log

It's a bit crude, but it works fine for myself, and keeps daily backups of the SQL data, and weekly ones of the website directory. If you want to take daily backups of the website directory, just remove the "if" and "fi" lines
 
I do basically the same thing as Calamity James -- take the site offline at roughly 4AM (nginx 503 redirect), mysqldump the databases, gzip the sql files, run some db maintenance, then bring the site back online. Once that's finished, a separate script rsyncs to a remote backup server.

However, I recently discovered Percona Xtrabackup, and am planning on testing that out with the intention of replacing mysqldumb with Xtrabackup. The nice thing about Xtrabackup is that it can run on a live db and recreate an internally-consistent data set in the backup file. I always take the site offline if I want to run mysqldump, just because I don't want to have to worry about table locking or partially-complete transactions or anything like that. My XenForo tables are now (mostly) InnoDB, but I still have some myisam stuff floating around.

You can read an overview of Xtrabackup here: http://www.percona.com/doc/percona-xtrabackup/how_xtrabackup_works.html
 
I do basically the same thing as Calamity James -- take the site offline at roughly 4AM (nginx 503 redirect), mysqldump the databases, gzip the sql files, run some db maintenance, then bring the site back online. Once that's finished, a separate script rsyncs to a remote backup server.

However, I recently discovered Percona Xtrabackup, and am planning on testing that out with the intention of replacing mysqldumb with Xtrabackup. The nice thing about Xtrabackup is that it can run on a live db and recreate an internally-consistent data set in the backup file. I always take the site offline if I want to run mysqldump, just because I don't want to have to worry about table locking or partially-complete transactions or anything like that. My XenForo tables are now (mostly) InnoDB, but I still have some myisam stuff floating around.

You can read an overview of Xtrabackup here: http://www.percona.com/doc/percona-xtrabackup/how_xtrabackup_works.html
Interesting. Thanks for that, I'll definitely consider that going forward, let me know how your testing pans out! :)
 
Steven, I wanted an automatic backup system and it looks like that http://backup-smart.com may be a good solution.

Anyone have discounts for that site or maybe other auto-backup systems/programs?


I use backup smart daily. It is well worth it and saved me millions of time. With XF though you have to restore from shell. I actually have an affiliate with them and I never support any program at all. They are my first. It has saved me millions of times on cilents with wordpress and XF.

One client saved him 9 times. He was getting hacked every four hours lol

Wordpress though you can use bigdump to restore.
XF for some reason does not like big dump due to foreign keys but shell does not care.
 
You can backup full file structure or all databases.You can not pick which db as it just does them all on M-F and the files you can choose to back them up or not.

I have six sites backing up with it. Wordpress, vbulletin, XF . It does not matter as it just uses your cpanel creditionals. I have bluehost , hostgator , etc.
 
Yes and if you run into issues just use shell to restore your database..

I always suggest testing a restore on another database, an empty one. I just recently ran into troubles with bigdump as I have foreign keys in database because of a mod and big dump can not handle that.

I have not had any issues with backup smart so far. I have it only backing up one XF though. All other stuff vb, wordpress, etc works fine .
 
Top Bottom