User Tools

Site Tools


build:backups

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
build:backups [2007/05/30 12:09]
71.10.176.218 Created some backup scripts. (CMB)
build:backups [2010/07/18 16:51] (current)
SLUUG Administration
Line 1: Line 1:
 ====== Backups ====== ====== Backups ======
  
-Like any system admins, we need to ensure that we have good backups. Our systems do not have tape backup devices, and it's easy to rebuild the OS, so we're just backing up our data and config files across the network.+Like any system admins, we need to ensure that we have good backups. Our systems do not have tape backup devices, and it's easy to rebuild the OS, so we're just backing up our data and config files across the network ​via rsync tunneled through SSH. 
 + 
 +We're also backing up locally to tarballs for easier access, and to have multiple versions of backups. 
  
 ===== Backup Dirs ===== ===== Backup Dirs =====
Line 8: Line 11:
 <code rootshell>​ <code rootshell>​
 mkdir -p /​var/​backups mkdir -p /​var/​backups
 +mkdir -p /​var/​backups/​bud
 +mkdir -p /​var/​backups/​budlight
 mkdir -p /​var/​backups/​etc mkdir -p /​var/​backups/​etc
 mkdir -p /​var/​backups/​home mkdir -p /​var/​backups/​home
 mkdir -p /​var/​backups/​usr_local mkdir -p /​var/​backups/​usr_local
 mkdir -p /​var/​backups/​email mkdir -p /​var/​backups/​email
 +mkdir -p /​var/​backups/​web
 +mkdir -p /​var/​backups/​mysql
 chmod -R 600 /​var/​backups chmod -R 600 /​var/​backups
 </​code>​ </​code>​
  
-===== Backup of /etc =====+===== Rsync Backups ===== 
 + 
 + 
 +For the procedure used for backups of michelob and dark using rsync, see [[rsync-aix]]. 
 + 
 +===== Tarball Backups ===== 
 + 
 + 
 +==== Backup of /etc ====
 Create the backup script in /​etc/​cron.daily/​backup-etc:​ Create the backup script in /​etc/​cron.daily/​backup-etc:​
 <code bash> <code bash>
Line 35: Line 50:
  
  
-===== Backup of /home =====+==== Backup of /home ====
 Note that we only do weekly backups of home, because it's a lot bigger than the other directories that we back up. Note that we only do weekly backups of home, because it's a lot bigger than the other directories that we back up.
  
Line 56: Line 71:
 Run the script to test that it works, and saves a file with the correct name in /​var/​backups/​home/​. Run 'tar tfz' on the resulting backup file to make sure it contains the expected files. Run the script to test that it works, and saves a file with the correct name in /​var/​backups/​home/​. Run 'tar tfz' on the resulting backup file to make sure it contains the expected files.
  
-===== Backup of /​usr/​local ​===== + 
-Create the backup script in /​etc/​cron.daily/​backup-user_local:+==== Backup of /usr/local ==== 
 +Create the backup script in /​etc/​cron.daily/​backup-usr_local:
 <code bash> <code bash>
 #!/bin/sh #!/bin/sh
  
 SRCDIR=/​usr/​local SRCDIR=/​usr/​local
-BACKUPDIR=/​var/​backups/​user_local+BACKUPDIR=/​var/​backups/​usr_local
 DATE=`date +'​%Y%m%d'​` DATE=`date +'​%Y%m%d'​`
  
-tar cfz $BACKUPDIR/user_local-$DATE.tgz -P $SRCDIR+tar cfz $BACKUPDIR/usr_local-$DATE.tgz -P $SRCDIR
 </​code>​ </​code>​
  
 Make the script executable: Make the script executable:
 <code rootshell>​ <code rootshell>​
-chmod 755 /​etc/​cron.daily/​backup-user_local+chmod 755 /​etc/​cron.daily/​backup-usr_local
 </​code>​ </​code>​
  
-Run the script to test that it works, and saves a file with the correct name in /​var/​backups/​user_local/. Run 'tar tfz' on the resulting backup file to make sure it contains the expected files.+Run the script to test that it works, and saves a file with the correct name in /​var/​backups/​usr_local/. Run 'tar tfz' on the resulting backup file to make sure it contains the expected files.
  
  
-===== Backup of Email ===== 
-NOTE: We currently store users' email folders in their home directories. So we do not need to back up anything separately at this point. 
  
  
 +==== Backup of Web Sites ====
 +NOTE: We currently store web sites in ''/​home/​web'',​ so we do not need to back up anything separately at this point.
 +
 +We do have a backup procedure for the wiki content. The ''/​etc/​cron.daily/​backup-dokuwiki''​ script copies a backup of the wiki data files to ''/​var/​backups/​web/''​.
 +
 +<code /​etc/​cron.daily/​backup-dokuwiki>​
 +#!/bin/sh
 + 
 +DATE=`date +'​%Y%m%d'​`
 +BACKUPDIR=/​var/​backups/​web
 +EXCLUDE='​data/​cache/​*'​
 +INCLUDE='​data/​ conf/'
 +WIKIDIR=/​srv/​www/​wiki.sluug.org/​public
 + 
 +tar cfz $BACKUPDIR/​wikidata-$DATE.tgz -C $WIKIDIR --exclude="​$EXCLUDE"​ $INCLUDE
 +
 +</​code>​
 +
 +This tars all other vhosts in /srv/www
 +
 +<code /​etc/​cron.daily/​backup-www>​
 +#!/bin/sh
 + 
 +SRCDIR=/​srv/​www
 +BACKUPDIR=/​var/​backups/​web
 +EXCLUDE='​wiki.sluug.org/​* wordpress*'​
 +DATE=`date +'​%Y%m%d'​`
 + 
 +tar cfz $BACKUPDIR/​www-$DATE.tgz -P $SRCDIR --exclude="​$EXCLUDE"​
 +</​code>​
 +
 +==== Backup of Email ====
 +NOTE: We currently store users' email folders in their home directories,​ so we do not need to back up anything separately at this point.
 +
 +==== Backup File Rotation ====
 +
 +TODO: We need to delete tarballs that get old, so we don't keep too many around. Would be nice to keep: 1 backup per day for 1 week (or 2 weeks); 1 backup per week for a year (or 1-6 months); 1 backup per month forever.
 +
 +
 +===== MySQL =====
 +
 +Decided not to use ''​mysqlhotcopy'',​ as it does not handle InnoDB databases, which some of our apps may require. So we're using ''​mysqldump''​. The ''​--add-locks''​ makes loading the resulting dump faster. The ''​--allow-keywords''​ allows fields to have the same name as SQL keywords. The ''​--create-options''​ includes MySQL-specific options on ''​CREATE TABLE''​ statements.
 +
 +<code rootshell>​
 +#!/bin/sh
 +BACKUPDIR=/​var/​backups/​mysql
 +DATE=`date +'​%Y%m%d'​`
 +mysqldump --all-databases --add-locks --allow-keywords --create-options > $BACKUPDIR/​mysql-$DATE.sql
 +gzip $BACKUPDIR/​mysql-$DATE.sql
 +</​code>​
 +
 +TODO: Add this to cron.
 ===== TODO ===== ===== TODO =====
  
Line 90: Line 156:
 Back up email folders separately, if/when they'​re no longer held in home directories. Back up email folders separately, if/when they'​re no longer held in home directories.
  
 +Take a look at [[http://​jeremy.zawodny.com/​mysql/​ | mysqlsnapshot]] to see if it might work better for MySQL backups. Note that it has not been updated for MySQL 4.x or 5.x, but it's a Perl script, so it might still work.
build/backups.1180544965.txt.gz · Last modified: 2007/05/30 12:09 by 71.10.176.218