mirror of https://github.com/deajan/obackup.git
102 lines
5.6 KiB
Bash
102 lines
5.6 KiB
Bash
#!/bin/bash
|
|
|
|
###### Remote (or local) backup script for files & databases
|
|
###### (C) 2013 by Ozy de Jong (www.badministrateur.com)
|
|
###### Config file rev 0408201301
|
|
|
|
## Backup identification, any string you want
|
|
BACKUP_ID="really-old-config-file"
|
|
|
|
## General backup options
|
|
BACKUP_SQL=yes
|
|
BACKUP_FILES=yes
|
|
|
|
## Local storage paths
|
|
LOCAL_SQL_STORAGE="${HOME}/obackup-storage/sql-old"
|
|
LOCAL_FILE_STORAGE="${HOME}/obackup-storage/files-old"
|
|
## Keep the absolute source path in your backup, eg: /your/backup/storage/the/remote/server/files
|
|
## You should leave this enabled if you use recursive directories backup lists or they'll all end in the same path.
|
|
LOCAL_STORAGE_KEEP_ABSOLUTE_PATHS=yes
|
|
## Generate an alert if backup size is lower than given value in Kb, useful for local mounted backups.
|
|
BACKUP_SIZE_MINIMUM=1024
|
|
## Generate an alert if local storage free space is lower than given value in Kb.
|
|
LOCAL_STORAGE_WARN_MIN_SPACE=1048576
|
|
|
|
## If enabled, file backups will be processed with sudo command. See documentation for /etc/sudoers configuration ("find", "du" and "rsync" need to be allowed). Requiretty needs to be disabled.
|
|
SUDO_EXEC=no
|
|
## Paranoia option. Don't change this unless you read the documentation and still feel concerned about security issues.
|
|
RSYNC_EXECUTABLE=rsync
|
|
|
|
## Remote options (will make backups of remote system through ssh tunnel, public RSA key need to be put into /home/.ssh/authorized_keys in remote users home directory)
|
|
REMOTE_BACKUP=yes
|
|
SSH_RSA_PRIVATE_KEY=${HOME}/.ssh/id_rsa_local
|
|
REMOTE_USER=root
|
|
REMOTE_HOST=localhost
|
|
REMOTE_PORT=22
|
|
## ssh compression should be used unless your remote connection is good enough (LAN)
|
|
SSH_COMPRESSION=yes
|
|
## Check for connectivity to remote host before launching remote backup tasks. Be sure the hosts responds to ping. Failing to ping will skip current task.
|
|
REMOTE_HOST_PING=yes
|
|
## Check for internet access by pinging one or more 3rd party hosts before remote backup tasks. Leave empty if you don't want this check to be be performed. Failing to ping will skip current task.
|
|
REMOTE_3RD_PARTY_HOST="www.kernel.org www.google.com"
|
|
|
|
## Databases options
|
|
SQL_USER=root
|
|
## Save all databases except the ones specified in the exlude list. Every found database will be backed up as separate task (see documentation for explanation about tasks)
|
|
DATABASES_ALL=yes
|
|
DATABASES_ALL_EXCLUDE_LIST="test;information_schema;zarafa_prod"
|
|
# Alternatively, you can specifiy a manual list of databases to backup separated by spaces
|
|
DATABASES_LIST=""
|
|
## Max backup execution time per DB task. Soft is warning only. Hard is warning, stopping backup task and processing next one. Time is specified in seconds
|
|
SOFT_MAX_EXEC_TIME_DB_TASK=3600
|
|
HARD_MAX_EXEC_TIME_DB_TASK=7200
|
|
## Preferred sql dump compression. Can be set to xz, lzma or gzip.
|
|
## Generally, xz level 5 is a good compromise between cpu, memory hunger and compress ratio. Gzipped files are set to be rsyncable.
|
|
COMPRESSION_PROGRAM=xz
|
|
COMPRESSION_LEVEL=3
|
|
## Dump compression should be done on remote side but can also be done locally to lower remote system usage (will take more bandwidth, check for ssh compression)
|
|
COMPRESSION_REMOTE=yes
|
|
|
|
## Path separator. You can set whatever seperator you want in your directories list below. You may change this in case you have some esoteric filenames (try to use unconventional separators like | ).
|
|
PATH_SEPARATOR_CHAR=";"
|
|
## File backup lists. Double quoted directory list separated by the $PATH_SEPARATOR_CHAR. Every directory will be processed as task (see documentation for explanation about tasks)
|
|
DIRECTORIES_SIMPLE_LIST="${HOME}/obackup-testdata/testData"
|
|
## Recurse directory list separated by the $PATH_SEPARATOR_CHAR. Will create a backup task per subdirectory (one level only), eg RECURSE_LIST="/home /var" will create tasks "/home/dir1", "/home/dir2", ... "/home/dirN", "/var/log", "/var/lib"... "/var/whatever"
|
|
DIRECTORIES_RECURSE_LIST="${HOME}/obackup-testdata/testDataRecursive"
|
|
## You can optionally exclude directories from RECURSE_LIST tasks, eg on the above example you could exclude /home/dir2 by adding it to RECURSE_EXCLUDE_LIST
|
|
DIRECTORIES_RECURSE_EXCLUDE_LIST="${HOME}/obackup-testdata/testDataRecursive/Excluded"
|
|
## Be aware that every recurse list will have it's own root (exclude pattern is relative from /home/web for /home/web/{recursedir})
|
|
RSYNC_EXCLUDE_PATTERN="*.ded"
|
|
## Preserve ACLS. Make sure target FS can hold ACLs or you'll get loads of errors.
|
|
PRESERVE_ACL=no
|
|
## Preserve Xattr
|
|
PRESERVE_XATTR=no
|
|
## Let RSYNC compress file transfers. Do not use if you already enabled SSH compression.
|
|
RSYNC_COMPRESS=yes
|
|
## Max execution time per file backup task. Soft is warning only. Hard is warning, stopping backup and processing next one one file list. Tilme is specified in seconds
|
|
SOFT_MAX_EXEC_TIME_FILE_TASK=3600
|
|
HARD_MAX_EXEC_TIME_FILE_TASK=7200
|
|
|
|
## Alert email adresses separated by a space character
|
|
DESTINATION_MAILS="ozy@netpower.fr"
|
|
|
|
## Max execution time of whole backup process. Soft is warning only. Hard is warning and stopping whole backup process.
|
|
SOFT_MAX_EXEC_TIME_TOTAL=30000
|
|
HARD_MAX_EXEC_TIME_TOTAL=36000
|
|
|
|
## Backup Rotation in case you don't use a snapshot aware file system like zfs or btrfs to perform a snapshot before every backup
|
|
ROTATE_BACKUPS=yes
|
|
ROTATE_COPIES=7
|
|
|
|
## Commands that will be run before and / or after backup execution (remote execution will only happen if REMOTE_BACKUP is set to yes). Very usefull to initiate snapshots.
|
|
## Set max execution time to 0 if you want these commands not to get stopped, else set a value in seconds after which execution will be stopped.
|
|
LOCAL_RUN_BEFORE_CMD=""
|
|
LOCAL_RUN_AFTER_CMD=""
|
|
|
|
REMOTE_RUN_BEFORE_CMD=""
|
|
REMOTE_RUN_AFTER_CMD=""
|
|
|
|
MAX_EXEC_TIME_PER_CMD_BEFORE=0
|
|
MAX_EXEC_TIME_PER_CMD_AFTER=0
|
|
|