Changes between Version 1 and Version 2 of faq/member-backup

May 2, 2011, 10:33:30 AM (10 years ago)
Daniel Strum



  • faq/member-backup

    v1 v2  
    11= How can I backup my own data? =
     3I created a very simple script to backup my files and database from the command line.
     7mysqldump [database-name] > ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql
     8tar cvzf ~/backups/[site]_backup_`date +%y%m%d`.tgz ~/[domain-directory]/web
     9rm -f ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql
     12Change the info inside the bracket for your own site. Save file as "". SSH into your server and create a new directory called "backups". Put the script in that directory and make it executable (chmod 755
     14The first line (after #!/bin/bash) dumps a dated copy of your database right into your web directory (maybe not the best practice but it gets deleted very fast).
     15The 2nd line creates in your "backups" directory a compressed tarball of everything in the "web" directory (including the database dump).
     16The 3rd line deletes the database dump from the "web" directory.
     18I would suggest first (after creating the "backups" directory) just running the 3 lines from your command line. The results should be a new dated *.tgz file in the "backups" directory. Also check that there is no *.sql file left in your "web" directory. If you have access errors doing the database dump, see here: []. If this works, try running the script:
     22After I run this I SFTP into the server and download the new backup to my local machine. I also keep the latest version on the server and delete the previous one. I do this periodically (every 2 weeks). I'm sure this could be easily improved but it works. I am looking at better options for automated back-up to cloud storage.