wiki:faq/member-backup

Version 4 (modified by anawillem, 14 years ago) ( diff )

--

How can I backup my own data?

PHPMyAdmin

This is the easiest way if you are less familiar with working on a command line.

  1. First you will want to know what server your website is on. You find that out by going to https://members.mayfirst.org and logging into your member's control panel. Once you are in, you will see the name of your server on the upper(ish) right hand part of the page:
Your primary host is: julia.mayfirst.org (209.234.249.204)
  1. Next you'll want to find out what your database password is. You'll do this by logging onto your site, navigating to the 'web/sites/default' folder, and downloading or reading the 'settings.php' file. That file will have a line with your database username and password in it in the following format:
$db_url = 'mysqli://[username]:[password]@localhost/[database]';
$db_prefix = '';
  1. Using the username and password in the settings.php file, navigate to the url of your primary host but add a '/phpmyadmin' to the end of that url and login:
https://julia.mayfirst.org/phpmyadmin
  1. Once you are in there will be the name of your database in the upper left-hand column. Click on your database name (not the one that says 'information_schema').
  1. In the main part of the page, you will see a series of tabs at the top of the page, click the tab that says 'Export'.
  1. In the page you are taken to, all of your database tables will be selected by default (the box on the upper lefthand corner of that page). If you have a LARGE database and you want to minimise the risk of taking up too much memory, deselect the database tables that have 'cache' (IE: cache_views, cache_blocks, etc) and the 'sessions' table.
  1. The default settings in phpmyadmin will work for a basic backup. Navigate to the bottom of the page, CHECK the 'Save as file' button and choose 'gzipped' as your compression. Name the file something like 'mysite_020111.backup' (the numbers being a 6 digit date without punctuation). The program will add a '.sql' to the end of your file, and save it you your computer in the default download folder when you click save.

If your browser times out during this operation or you experience other issues, please submit a support ticket to Mayfirst People link and us know.

COMMAND LINE

I created a very simple script to backup my files and database from the command line.

#!/bin/bash
mysqldump [database-name] > ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql
tar cvzf ~/backups/[site]_backup_`date +%y%m%d`.tgz ~/[domain-directory]/web
rm -f ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql

Copy and paste this text into a program like notepad, textedit or wordpad. Change the info inside the bracket [] for your own site. Save file as "backup.sh". SSH into your server and create a new directory called "backups". Put the script in that directory and make it executable (chmod 755 backup.sh).

The 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). The 2nd line creates in your "backups" directory a compressed tarball of everything in the "web" directory (including the database dump). The 3rd line deletes the database dump from the "web" directory.

I 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: https://support.mayfirst.org/wiki/mysql_command_line_access. If this works, try running the script:

./backups/backup.sh

After 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.

Note: See TracWiki for help on using the wiki.