Changes between Version 5 and Version 6 of faq/member-backup


Ignore:
Timestamp:
Jul 4, 2011, 3:22:37 PM (14 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • faq/member-backup

    v5 v6  
    22= How can I backup my own data? =
    33
    4 == PHPMyAdmin ==
     4Even though May First/People Link backs up your data to both an onsite and offsite backup server, you are still encouraged to a backup your own data regularly.
    55
    6 This is the easiest way if you are less familiar with working on a command line.
     6== What should I backup? ==
    77
    8 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:
     8After logging into your account using either [wiki:sftp sftp] or [wiki:secure_shell ssh], you should see a directory named after your domain name, e.g. mayfirst.org.
    99
    10 {{{
    11 Your primary host is: julia.mayfirst.org (209.234.249.204)
    12 }}}
     10In that directory you will see:
    1311
    14 2. 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:
     12 * backups: contains daily database dumps. You should include this directory in your backup.
     13 * bin: contains scripts to launch PHP for php-enabled web site, usually not modified by members. You should include this directory in your backup.
     14 * cgi-bin: default location for perl, python and other web-site scripts, usually not used by members. You should include this directory in your backup.
     15 * include: location for optional configuration files for your web site. You should include this directory in your backup.
     16 * logs: access and error logs for your web site. You may optionally include this location in your backup.
     17 * users: user email and personal data. You should not include this directory in your web backup since the user that can access your web data may not have persmission to read data in your user directory.
     18 * web: contains all your web site files. You should include this directory in your backup.
    1519
    16 {{{
    17 $db_url = 'mysqli://[username]:[password]@localhost/[database]';
    18 $db_prefix = '';
    19 }}}
     20== How should I back it up? ==
    2021
    21 3. 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:
     22=== Secure FTP ===
    2223
    23 {{{
    24 https://julia.mayfirst.org/phpmyadmin
    25 }}}
     24The simplest method for backing your data is to manually and periodically use [wiki:sftp an Secure FTP client] to copy that data from the server to your desktop. This is simple and it's easy to confirm that it is complete.
    2625
    27 4. 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').
     26However, it requires that you remember to run it regularly.
    2827
    29 5. 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'.
     28=== Automated systems ===
    3029
    31 6. 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.
     30[https://sites.google.com/site/thebackupmonkey/home Bonkey is a free/open source program for Windows and Macintosh]
    3231
    33 7. 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.
    34 
    35 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.
    36 
    37 
    38 == COMMAND LINE ==
    39 
    40 I created a very simple script to backup my files and database from the command line.
    41 
    42 {{{
    43 #!/bin/bash
    44 mysqldump [database-name] > ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql
    45 tar cvzf ~/backups/[site]_backup_`date +%y%m%d`.tgz ~/[domain-directory]/web
    46 rm -f ~/[domain-directory]/web/[database-name]_`date +%y%m%d`.sql
    47 }}}
    48 
    49 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).
    50 
    51 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).
    52 The 2nd line creates in your "backups" directory a compressed tarball of everything in the "web" directory (including the database dump).
    53 The 3rd line deletes the database dump from the "web" directory.
    54 
    55 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:
    56 {{{
    57 ./backups/backup.sh
    58 }}}
    59 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.
     32[http://www.techdrivein.com/2010/12/top-5-open-source-backup-software-for.html Several programs are available for Linux as well.]
    6033
    6134== Backup and Migrate ==