User Tools

Site Tools


backup

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
backup [2012/06/11 15:17]
aorth
— (current)
Line 1: Line 1:
-====== Backups ====== 
  
-We utilize three methods for backups: 
-  * [[backup:​amanda|Amanda]] - backs up data to a tape library connected to the HPC 
-  * [[backup:​rsync|rsync]] - for files not stored on the HPC (other websites, etc) 
-  * [[backup:​backuppc|BackupPC]] - for files on users' desktops 
-  * [[backup:​scripts|Backup scripts]] - for backing up MySQL, PostgreSQL, etc via cron 
- 
-====== Example Scripts ====== 
-Example scripts to be used on ILRI servers for automated backup and maintenance of data.  Most should be configured to run via cron, usually as root.  Make sure that any critical scripts are protected by changing the permissions to 700 so only root can read them. 
- 
-To add a cron entry, edit root's cron tab: 
-<​code>​$ sudo crontab -e</​code>​ 
-... to contain the following lines: 
-<​file>#​ Backup the MySQL database at 12:13 every night 
-13 0 * * * /​home/​backup/​scripts/​backup_mysql.sh</​file>​ 
-Which will run the script every night at 12:13. 
- 
-===== Backup MySQL Database ===== 
-This script will dump a given database to a ''​mysql''​ folder in the specified backup directory. ​ Make sure the backup directory and the ''​mysql''​ subdirectory exist. 
-<​code>#​!/​bin/​sh 
- 
-BACKUP_DIR=/​home/​backup 
-DATE=$(date +%Y%m%d) 
- 
-mysqldump --opt -u root -p'​yourpassword'​ databasename | bzip2 -c > ${BACKUP_DIR}/​mysql/​databasename_${DATE}.sql.bz2 
- 
-exit 0 
-</​code>​ 
- 
-===== Backup PostgreSQL Database ===== 
-This script will dump a given database to a ''​postgres''​ folder in the specified backup directory. ​ Make sure the backup directory and the ''​postgres''​ subdirectory exist. 
-<​code>#​!/​bin/​sh 
- 
-# set the user's Postgres password in the variable because we are 
-# not using pg_dump interactively,​ so we can't type it in! 
-export PGPASSWORD="​database password"​ 
- 
-# Grab the current date and save it to the DATE variable. 
-# February 22, 2010 would look like this: 20100222 
-DATE=$(date +%Y%m%d) 
- 
-# Backup the PostgreSQL dspace database at 12:15 every night 
-/​usr/​bin/​pg_dump -b -v -o --format=custom -U user /​home/​backup/​postgres/​database_${DATE}.backup database 
- 
-exit 0</​code>​ 
-===== Cleanup Old Backups ===== 
-This script will search the specified backup directory for backup files older than 2 weeks and delete them.  Make sure you don't delete backup scripts or non-backup files (directories,​ maybe?). 
-<​code>#​!/​bin/​sh 
- 
-BACKUP_DIR="/​home/​backup"​ 
- 
-# Find files older than 2 weeks and delete them 
-find ${BACKUP_DIR} -type f \! -newermt "2 weeks ago" \! -name "​*.sh"​ -exec rm {} \; 
- 
-exit 0</​code>​ 
backup.1339417026.txt.gz · Last modified: 2012/06/11 15:17 by aorth