1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Any way to regurarly backup the xenForo database?

Discussion in 'XenForo Questions and Support' started by Marco Famà, Mar 15, 2012.

  1. Marco Famà

    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,
    Akela likes this.
  2. principia

    principia Well-Known Member

  3. Calamity James

    Calamity James Active Member

    I set up a crontab on my server to back everything up...

    # XenForo backup script
    #set database connection info
    # set filenames
    filename_sql="backup-db-"`eval date +%Y%m%d`".sql"
    filename_sql_gz="backup-db-"`eval date +%Y%m%d`".gz"
    # set path to backups and website directory without trailing slashes
    # 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
    # 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
    Vicotex, planetzu, Kiwi and 8 others like this.
  4. Ingenious

    Ingenious Well-Known Member

    Thanks for this CJ - I log in manually via SSH and always thought there must be an easier way to do this!
  5. Marco Famà

    Marco Famà Active Member

    I would think about integrating such a feature in the future upgrade... maybe someone is "listening" to us :p
  6. Calamity James

    Calamity James Active Member

    Whoops, I made a couple of mistakes when removing my databases information. I've edited the post and that should be fine now!
    Ingenious likes this.
  7. shawn

    shawn Well-Known Member

    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
    Marco Famà likes this.
  8. steven s

    steven s Well-Known Member

    Kiwi, Marco Famà and ArnyVee like this.
  9. Calamity James

    Calamity James Active Member

    Interesting. Thanks for that, I'll definitely consider that going forward, let me know how your testing pans out! :)
    simbolo likes this.
  10. ArnyVee

    ArnyVee Well-Known Member

    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?
  11. ArnyVee

    ArnyVee Well-Known Member

    Just found this one: http://www.fbackup.com/

    It's free and you can set it to automatically back things up. Anyone ever used it before?
    maszd and Marco Famà like this.
  12. mmoore5553

    mmoore5553 Well-Known Member

    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.
    Kiwi likes this.
  13. Andy.N

    Andy.N Well-Known Member

    Does this do incremental backup?
    What if I have multiple servers for mysql, web, etc. What do they backup?
  14. mmoore5553

    mmoore5553 Well-Known Member

    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.
    Kiwi likes this.
  15. Eric Russell

    Eric Russell Active Member

    I was just reading on there website. Is it really just a click of a button to restore?
  16. mmoore5553

    mmoore5553 Well-Known Member

    To be honest i have never restored from the application. I just moved the backup via FTP and then ran bigdump. I can test this weekend to see how that restore works. I just found big dump easy to use.
  17. mmoore5553

    mmoore5553 Well-Known Member

    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 .
    Eric Russell likes this.
  18. Andy.N

    Andy.N Well-Known Member

    Oh, I don't use cpanel so I guess backup-smart is no use to me.
  19. mmoore5553

    mmoore5553 Well-Known Member

    Andy you are correct. Backup smart only drawback is you must use cpanel but every server i have I made sure that was with it.
  20. steven s

    steven s Well-Known Member

    I've ftp'd my backup too. I don't trust myself with SSH.

Share This Page