backup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| backup [2012/06/11 12:16] – aorth | backup [2019/05/08 09:35] (current) – removed aorth | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Backups ====== | ||
| - | We utilize three methods for backups: | ||
| - | * [[backup: | ||
| - | * [[backup: | ||
| - | * [[backup: | ||
| - | * [[backup: | ||
| - | * | ||
| - | ====== 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: | ||
| - | < | ||
| - | ... to contain the following lines: | ||
| - | < | ||
| - | 13 0 * * * / | ||
| - | Which will run the script every night at 12:13. | ||
| - | |||
| - | ===== Backup MySQL Database ===== | ||
| - | This script will dump a given database to a '' | ||
| - | < | ||
| - | |||
| - | BACKUP_DIR=/ | ||
| - | DATE=$(date +%Y%m%d) | ||
| - | |||
| - | mysqldump --opt -u root -p' | ||
| - | |||
| - | exit 0 | ||
| - | </ | ||
| - | |||
| - | ===== Backup PostgreSQL Database ===== | ||
| - | This script will dump a given database to a '' | ||
| - | < | ||
| - | |||
| - | # set the user's Postgres password in the variable because we are | ||
| - | # not using pg_dump interactively, | ||
| - | export PGPASSWORD=" | ||
| - | |||
| - | # 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 | ||
| - | / | ||
| - | |||
| - | exit 0</ | ||
| - | ===== 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, | ||
| - | < | ||
| - | |||
| - | BACKUP_DIR="/ | ||
| - | |||
| - | # Find files older than 2 weeks and delete them | ||
| - | find ${BACKUP_DIR} -type f \! -newermt "2 weeks ago" \! -name " | ||
| - | |||
| - | exit 0</ | ||
backup.1339416994.txt.gz · Last modified: by aorth
