diff --git a/dev/tests/conf-travis/local-max-exec-time.conf b/dev/tests/conf/local-max-exec-time.conf similarity index 100% rename from dev/tests/conf-travis/local-max-exec-time.conf rename to dev/tests/conf/local-max-exec-time.conf diff --git a/dev/tests/conf-travis/local.conf b/dev/tests/conf/local.conf similarity index 99% rename from dev/tests/conf-travis/local.conf rename to dev/tests/conf/local.conf index 545b420..cb6d8d2 100644 --- a/dev/tests/conf-travis/local.conf +++ b/dev/tests/conf/local.conf @@ -27,7 +27,7 @@ SQL_STORAGE="${HOME}/obackup-storage/sql" FILE_STORAGE="${HOME}/obackup-storage/files" ## Encryption -ENCRYPTION=yes +ENCRYPTION=no ## Backup encryption needs a temporary storage space in order to encrypt files before sending them (absolute paths of the local or remote system) CRYPT_STORAGE="${HOME}/obackup-storage/crypt" diff --git a/dev/tests/conf-travis/old.conf b/dev/tests/conf/old.conf similarity index 98% rename from dev/tests/conf-travis/old.conf rename to dev/tests/conf/old.conf index 4c0577b..8d0d2e5 100644 --- a/dev/tests/conf-travis/old.conf +++ b/dev/tests/conf/old.conf @@ -30,15 +30,15 @@ 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=travis +REMOTE_USER=root REMOTE_HOST=localhost -REMOTE_PORT=22 +REMOTE_PORT=49999 ## 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=no +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="" +REMOTE_3RD_PARTY_HOST="www.kernel.org www.google.com" ## Databases options SQL_USER=root diff --git a/dev/tests/conf-travis/pull.conf b/dev/tests/conf/pull.conf similarity index 98% rename from dev/tests/conf-travis/pull.conf rename to dev/tests/conf/pull.conf index 5caf908..24d1974 100644 --- a/dev/tests/conf-travis/pull.conf +++ b/dev/tests/conf/pull.conf @@ -56,7 +56,7 @@ FILE_WARN_MIN_SPACE=1048576 ###### REMOTE ONLY OPTIONS ## In case of pulled or pushed backups, remote system URI needs to be supplied. -REMOTE_SYSTEM_URI="ssh://travis@localhost:22/" +REMOTE_SYSTEM_URI="ssh://root@localhost:49999/" ## You can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information. SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local" @@ -71,10 +71,10 @@ SSH_IGNORE_KNOWN_HOSTS=no RSYNC_REMOTE_PATH="" ## 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=no +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_HOSTS="" +REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com" ## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled. SUDO_EXEC=no diff --git a/dev/tests/conf/pull.conf.tmp b/dev/tests/conf/pull.conf.tmp new file mode 100644 index 0000000..9be18d1 --- /dev/null +++ b/dev/tests/conf/pull.conf.tmp @@ -0,0 +1,228 @@ +#!/usr/bin/env bash + +###### obackup - Local or Remote, push or pull backup script for files & mysql databases +###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr) +###### obackup v2.1x config file rev 2016081701 + +###### GENERAL BACKUP OPTIONS + +## Backup identification string. +INSTANCE_ID="pull-test" + +## Log file location. Leaving this empty will create log file at /var/log/obackup.INSTANCE_ID.log (or current directory if /var/log doesn't exist). +LOGFILE="" + +## Elements to backup +SQL_BACKUP=yes +FILE_BACKUP=yes + +## Backups can be done local, pulled from another server or pushed to a backup server. Available options are [local,pull,push]. +## Pulled backups are the safest option, as the backup server contains the RSA key and cannot be compromised by another server. +BACKUP_TYPE=pull + +###### BACKUP STORAGE + +## Storage paths of the backups (absolute paths of the local or remote system) +SQL_STORAGE="${HOME}/obackup-storage/sql-pull" +FILE_STORAGE="${HOME}/obackup-storage/files-pull" + +## Encryption +ENCRYPTION=no + +## Backup encryption needs a temporary storage space in order to encrypt files before sending them (absolute paths of the local or remote system) +CRYPT_STORAGE="${HOME}/obackup-storage/crypt" + +## GPG recipient (pubkey for this recipient must exist, see gpg2 --list-keys or gpg --list-keys +GPG_RECIPIENT="John Doe" + +## Create backup directories if they do not exist +CREATE_DIRS=yes + +## Keep absolute source path in your backup, eg: /your/backup/storage/the/remote/server/files +## You should leave this enabled if you intend to use 'backup task division' functionality of oBackup, or everything will end up in the same directory. +KEEP_ABSOLUTE_PATHS=yes + +## Generate an alert if backup size is lower than given value in Kb (this can also help identifying empty mount dirs). +BACKUP_SIZE_MINIMUM=1024 + +## Check backup size before proceeding +GET_BACKUP_SIZE=yes + +## Generate an alert if storage free space is lower than given value in Kb. +## Keep in mind that disabling backup file size test will only test min space against SQL backup size. +SQL_WARN_MIN_SPACE=1048576 +FILE_WARN_MIN_SPACE=1048576 + +###### REMOTE ONLY OPTIONS + +## In case of pulled or pushed backups, remote system URI needs to be supplied. +REMOTE_SYSTEM_URI="ssh://root@localhost:22/" + +## You can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information. +SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local" + +## ssh compression should be used unless your remote connection is good enough (LAN) +SSH_COMPRESSION=yes + +## Ignore ssh known hosts verification. DANGER WILL ROBINSON DANGER: This can lead to security risks. Only enable if you know what you're doing. +SSH_IGNORE_KNOWN_HOSTS=no + +## Remote rsync executable path. Leave this empty in most cases +RSYNC_REMOTE_PATH="" + +## 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_HOSTS="www.kernel.org www.google.com" + +## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled. +SUDO_EXEC=no + +###### DATABASE SPECIFIC OPTIONS + +## Database backup user +SQL_USER=root + +## Enabling the following option will save all databases on local or remote given SQL instance except the ones specified in the exclude list. +## Every found database will be backed up as separate backup task. +DATABASES_ALL=yes +DATABASES_ALL_EXCLUDE_LIST="test;information_schema;zarafa_prod" +## Alternatively, if DATABASES_ALL=no, you can specify a list of databases to backup separated by spaces. +DATABASES_LIST="mysql" + +## Max backup execution time per Database task. Soft max exec time generates a warning only. Hard max exec time generates a warning and stops current backup task. +## If a task gets stopped, next one in the task list gets executed. Time is specified in seconds. +SOFT_MAX_EXEC_TIME_DB_TASK=3600 +HARD_MAX_EXEC_TIME_DB_TASK=7200 + +## mysqldump options (ex: --extended-insert, --single-transaction, --quick...). See MySQL / MariaDB manual +## default option: --opt +MYSQLDUMP_OPTIONS="--opt --single-transaction" + +## Preferred SQL dump compression. Compression methods can be xz, lzma, pigz or gzip (will fallback from xz to gzip depending if available) +## Generally, level 5 is a good compromise between cpu, memory hunger and compress ratio. Gzipped files are set to be rsyncable. +COMPRESSION_LEVEL=3 + +###### FILES SPECIFIC OPTIONS + +## File backups are divided in tasks. Every directory in DIRECTORY_LIST will be processed as a unique task. +## Every subdirectory of each directory in RECURSIVE_DIRECTORY_LIST will be processed as a unique task. +## Example: RECURSIVE_DIRECTORY_LIST="/home;/var" will create backup tasks tasks "/home/dir1, "/home/dir2", ... "/home/dirN", "/var/log", "/var/lib"... "/var/something". +## You can exclude directories from the avove backup task creation, ex: avoid backing up "/home/dir2" by adding it to RECURSIVE_EXCLUDE_LIST. + +## Directories backup list. List of semicolon separated directories that will be backed up. +DIRECTORY_LIST="${HOME}/obackup-testdata/testData" +RECURSIVE_DIRECTORY_LIST="${HOME}/obackup-testdata/testDataRecursive" +RECURSIVE_EXCLUDE_LIST="${HOME}/obackup-testdata/testDataRecursive/Excluded" + +## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns) +RSYNC_PATTERN_FIRST=include + +## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work). +## Paths are relative to sync dirs. List elements are separated by a semicolon. +RSYNC_INCLUDE_PATTERN="" +RSYNC_EXCLUDE_PATTERN="*.ded" +#RSYNC_EXCLUDE_PATTERN="tmp;archives" + +## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file. +## This file has to be in the same directory as the config file +## Paths are relative to sync dirs. One element per line. +RSYNC_INCLUDE_FROM="" +RSYNC_EXCLUDE_FROM="" +#RSYNC_EXCLUDE_FROM="exclude.list" + +## List separator char. You may set an alternative separator char for your directories lists above. +PATH_SEPARATOR_CHAR=";" + +## Preserve basic linux permissions +PRESERVE_PERMISSIONS=yes +PRESERVE_OWNER=yes +PRESERVE_GROUP=yes +## On MACOS X, does not work and will be ignored +PRESERVE_EXECUTABILITY=yes + +## Preserve ACLS. Make sure source and target FS can hold same ACLs or you'll get loads of errors. +PRESERVE_ACL=no +## Preserve Xattr. MAke sure source and target FS can hold same Xattr or you'll get loads of errors. +PRESERVE_XATTR=no + +## Transforms symlinks into referent files/dirs +COPY_SYMLINKS=yes +## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root. +KEEP_DIRLINKS=yes +## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them. +PRESERVE_HARDLINKS=no + + +## Let RSYNC compress file transfers. Do not use this on local-local backup schemes. Also, this is not useful if SSH compression is enabled. +RSYNC_COMPRESS=no + +## 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 + +## Keep partial uploads that can be resumed on next run, experimental feature +PARTIAL=no + +## Delete files on destination that vanished from source. Do not turn this on unless you enabled backup rotation or a snapshotting FS like zfs to keep those vanished files on the destination. +DELETE_VANISHED_FILES=no + +## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes +DELTA_COPIES=yes + +## Bandwidth limit Kbytes / second for file backups. Leave 0 to disable limitation. +BANDWIDTH=0 + +## Paranoia option. Don't change this unless you read the documentation. +RSYNC_EXECUTABLE=rsync + +###### ALERT OPTIONS + +## Alert email addresses separated by a space character +DESTINATION_MAILS="ozy@netpower.fr" + +## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/ +SENDER_MAIL="alert@your.system.tld" +SMTP_SERVER=smtp.your.isp.tld +SMTP_PORT=25 +# encryption can be tls, ssl or none +SMTP_ENCRYPTION=none +SMTP_USER= +SMTP_PASSWORD= + +###### GENERAL BACKUP OPTIONS + +## Max execution time of whole backup process. Soft max exec time generates a warning only. +## Hard max exec time generates a warning and stops the whole backup execution. +SOFT_MAX_EXEC_TIME_TOTAL=30000 +HARD_MAX_EXEC_TIME_TOTAL=36000 + +## Log a message every KEEP_LOGGING seconds just to know the task is still alive +KEEP_LOGGING=1801 + +## Backup Rotation. You may rotate backups if you don't use snapshots on your backup server. +ROTATE_SQL_BACKUPS=yes +ROTATE_SQL_COPIES=7 +ROTATE_FILE_BACKUPS=yes +ROTATE_FILE_COPIES=7 + +###### EXECUTION HOOKS + +## Commands can will be run before and / or after backup execution (remote execution will only happen if REMOTE_BACKUP is set). +## This is useful to make a snapshot before backing up data, or even handle snapshots of backed up data. +LOCAL_RUN_BEFORE_CMD="" +LOCAL_RUN_AFTER_CMD="" + +REMOTE_RUN_BEFORE_CMD="" +REMOTE_RUN_AFTER_CMD="" + +## Max execution time of commands before they get force killed. Leave 0 if you don't want this to happen. Time is specified in seconds. +MAX_EXEC_TIME_PER_CMD_BEFORE=0 +MAX_EXEC_TIME_PER_CMD_AFTER=0 + +## Stops whole backup execution if one of the above commands fail +STOP_ON_CMD_ERROR=no + +## Run local and remote after backup cmd's even on failure +RUN_AFTER_CMD_ON_ERROR=yes diff --git a/dev/tests/conf-travis/push.conf b/dev/tests/conf/push.conf similarity index 98% rename from dev/tests/conf-travis/push.conf rename to dev/tests/conf/push.conf index c2f3c9f..c562db5 100644 --- a/dev/tests/conf-travis/push.conf +++ b/dev/tests/conf/push.conf @@ -56,7 +56,7 @@ FILE_WARN_MIN_SPACE=1048576 ###### REMOTE ONLY OPTIONS ## In case of pulled or pushed backups, remote system URI needs to be supplied. -REMOTE_SYSTEM_URI="ssh://travis@localhost:22/" +REMOTE_SYSTEM_URI="ssh://root@localhost:49999/" ## You can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information. SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local" @@ -71,10 +71,10 @@ SSH_IGNORE_KNOWN_HOSTS=no RSYNC_REMOTE_PATH="" ## 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=no +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_HOSTS="" +REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com" ## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled. SUDO_EXEC=no diff --git a/dev/tests/conf/push.conf.tmp b/dev/tests/conf/push.conf.tmp new file mode 100644 index 0000000..02432d8 --- /dev/null +++ b/dev/tests/conf/push.conf.tmp @@ -0,0 +1,228 @@ +#!/usr/bin/env bash + +###### obackup - Local or Remote, push or pull backup script for files & mysql databases +###### (C) 2013-2016 by Orsiris de Jong (www.netpower.fr) +###### obackup v2.1x config file rev 2016081701 + +###### GENERAL BACKUP OPTIONS + +## Backup identification string. +INSTANCE_ID="push-test" + +## Log file location. Leaving this empty will create log file at /var/log/obackup.INSTANCE_ID.log (or current directory if /var/log doesn't exist). +LOGFILE="" + +## Elements to backup +SQL_BACKUP=yes +FILE_BACKUP=yes + +## Backups can be done local, pulled from another server or pushed to a backup server. Available options are [local,pull,push]. +## Pulled backups are the safest option, as the backup server contains the RSA key and cannot be compromised by another server. +BACKUP_TYPE=push + +###### BACKUP STORAGE + +## Storage paths of the backups (absolute paths of the local or remote system) +SQL_STORAGE="${HOME}/obackup-storage/sql-push" +FILE_STORAGE="${HOME}/obackup-storage/files-push" + +## Encryption +ENCRYPTION=no + +## Backup encryption needs a temporary storage space in order to encrypt files before sending them (absolute paths of the local or remote system) +CRYPT_STORAGE="${HOME}/obackup-storage/crypt" + +## GPG recipient (pubkey for this recipient must exist, see gpg2 --list-keys or gpg --list-keys +GPG_RECIPIENT="John Doe" + +## Create backup directories if they do not exist +CREATE_DIRS=yes + +## Keep absolute source path in your backup, eg: /your/backup/storage/the/remote/server/files +## You should leave this enabled if you intend to use 'backup task division' functionality of oBackup, or everything will end up in the same directory. +KEEP_ABSOLUTE_PATHS=yes + +## Generate an alert if backup size is lower than given value in Kb (this can also help identifying empty mount dirs). +BACKUP_SIZE_MINIMUM=1024 + +## Check backup size before proceeding +GET_BACKUP_SIZE=yes + +## Generate an alert if storage free space is lower than given value in Kb. +## Keep in mind that disabling backup file size test will only test min space against SQL backup size. +SQL_WARN_MIN_SPACE=1048576 +FILE_WARN_MIN_SPACE=1048576 + +###### REMOTE ONLY OPTIONS + +## In case of pulled or pushed backups, remote system URI needs to be supplied. +REMOTE_SYSTEM_URI="ssh://root@localhost:22/" + +## You can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information. +SSH_RSA_PRIVATE_KEY="${HOME}/.ssh/id_rsa_local" + +## ssh compression should be used unless your remote connection is good enough (LAN) +SSH_COMPRESSION=yes + +## Ignore ssh known hosts verification. DANGER WILL ROBINSON DANGER: This can lead to security risks. Only enable if you know what you're doing. +SSH_IGNORE_KNOWN_HOSTS=no + +## Remote rsync executable path. Leave this empty in most cases +RSYNC_REMOTE_PATH="" + +## 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_HOSTS="www.kernel.org www.google.com" + +## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled. +SUDO_EXEC=no + +###### DATABASE SPECIFIC OPTIONS + +## Database backup user +SQL_USER=root + +## Enabling the following option will save all databases on local or remote given SQL instance except the ones specified in the exclude list. +## Every found database will be backed up as separate backup task. +DATABASES_ALL=yes +DATABASES_ALL_EXCLUDE_LIST="test;information_schema;zarafa_prod" +## Alternatively, if DATABASES_ALL=no, you can specify a list of databases to backup separated by spaces. +DATABASES_LIST="mysql" + +## Max backup execution time per Database task. Soft max exec time generates a warning only. Hard max exec time generates a warning and stops current backup task. +## If a task gets stopped, next one in the task list gets executed. Time is specified in seconds. +SOFT_MAX_EXEC_TIME_DB_TASK=3600 +HARD_MAX_EXEC_TIME_DB_TASK=7200 + +## mysqldump options (ex: --extended-insert, --single-transaction, --quick...). See MySQL / MariaDB manual +## default option: --opt +MYSQLDUMP_OPTIONS="--opt --single-transaction" + +## Preferred SQL dump compression. Compression methods can be xz, lzma, pigz or gzip (will fallback from xz to gzip depending if available) +## Generally, level 5 is a good compromise between cpu, memory hunger and compress ratio. Gzipped files are set to be rsyncable. +COMPRESSION_LEVEL=3 + +###### FILES SPECIFIC OPTIONS + +## File backups are divided in tasks. Every directory in DIRECTORY_LIST will be processed as a unique task. +## Every subdirectory of each directory in RECURSIVE_DIRECTORY_LIST will be processed as a unique task. +## Example: RECURSIVE_DIRECTORY_LIST="/home;/var" will create backup tasks tasks "/home/dir1, "/home/dir2", ... "/home/dirN", "/var/log", "/var/lib"... "/var/something". +## You can exclude directories from the avove backup task creation, ex: avoid backing up "/home/dir2" by adding it to RECURSIVE_EXCLUDE_LIST. + +## Directories backup list. List of semicolon separated directories that will be backed up. +DIRECTORY_LIST="${HOME}/obackup-testdata/testData" +RECURSIVE_DIRECTORY_LIST="${HOME}/obackup-testdata/testDataRecursive" +RECURSIVE_EXCLUDE_LIST="${HOME}/obackup-testdata/testDataRecursive/Excluded" + +## Rsync exclude / include order (the option set here will be set first, eg: include will make include then exclude patterns) +RSYNC_PATTERN_FIRST=include + +## List of files / directories to incldue / exclude from sync on both sides (see rsync patterns, wildcards work). +## Paths are relative to sync dirs. List elements are separated by a semicolon. +RSYNC_INCLUDE_PATTERN="" +RSYNC_EXCLUDE_PATTERN="*.ded" +#RSYNC_EXCLUDE_PATTERN="tmp;archives" + +## Files that contains lists of files / directories to include / exclude from sync on both sides. Leave this empty if you don't want to use an exclusion file. +## This file has to be in the same directory as the config file +## Paths are relative to sync dirs. One element per line. +RSYNC_INCLUDE_FROM="" +RSYNC_EXCLUDE_FROM="" +#RSYNC_EXCLUDE_FROM="exclude.list" + +## List separator char. You may set an alternative separator char for your directories lists above. +PATH_SEPARATOR_CHAR=";" + +## Preserve basic linux permissions +PRESERVE_PERMISSIONS=yes +PRESERVE_OWNER=yes +PRESERVE_GROUP=yes +## On MACOS X, does not work and will be ignored +PRESERVE_EXECUTABILITY=yes + +## Preserve ACLS. Make sure source and target FS can hold same ACLs or you'll get loads of errors. +PRESERVE_ACL=no +## Preserve Xattr. MAke sure source and target FS can hold same Xattr or you'll get loads of errors. +PRESERVE_XATTR=no + +## Transforms symlinks into referent files/dirs +COPY_SYMLINKS=yes +## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root. +KEEP_DIRLINKS=yes +## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them. +PRESERVE_HARDLINKS=no + + +## Let RSYNC compress file transfers. Do not use this on local-local backup schemes. Also, this is not useful if SSH compression is enabled. +RSYNC_COMPRESS=no + +## 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 + +## Keep partial uploads that can be resumed on next run, experimental feature +PARTIAL=no + +## Delete files on destination that vanished from source. Do not turn this on unless you enabled backup rotation or a snapshotting FS like zfs to keep those vanished files on the destination. +DELETE_VANISHED_FILES=no + +## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes +DELTA_COPIES=yes + +## Bandwidth limit Kbytes / second for file backups. Leave 0 to disable limitation. +BANDWIDTH=0 + +## Paranoia option. Don't change this unless you read the documentation. +RSYNC_EXECUTABLE=rsync + +###### ALERT OPTIONS + +## Alert email addresses separated by a space character +DESTINATION_MAILS="ozy@netpower.fr" + +## Windows specific (msys / cygwin environment) only mail options (used with mailsend.exe from muquit, http://github.com/muquit/mailsend or from sendemail.exe from Brandon Zehm, http://caspian.dotconf.net/menu/Software/SendEmail/ +SENDER_MAIL="alert@your.system.tld" +SMTP_SERVER=smtp.your.isp.tld +SMTP_PORT=25 +# encryption can be tls, ssl or none +SMTP_ENCRYPTION=none +SMTP_USER= +SMTP_PASSWORD= + +###### GENERAL BACKUP OPTIONS + +## Max execution time of whole backup process. Soft max exec time generates a warning only. +## Hard max exec time generates a warning and stops the whole backup execution. +SOFT_MAX_EXEC_TIME_TOTAL=30000 +HARD_MAX_EXEC_TIME_TOTAL=36000 + +## Log a message every KEEP_LOGGING seconds just to know the task is still alive +KEEP_LOGGING=1801 + +## Backup Rotation. You may rotate backups if you don't use snapshots on your backup server. +ROTATE_SQL_BACKUPS=yes +ROTATE_SQL_COPIES=7 +ROTATE_FILE_BACKUPS=yes +ROTATE_FILE_COPIES=7 + +###### EXECUTION HOOKS + +## Commands can will be run before and / or after backup execution (remote execution will only happen if REMOTE_BACKUP is set). +## This is useful to make a snapshot before backing up data, or even handle snapshots of backed up data. +LOCAL_RUN_BEFORE_CMD="" +LOCAL_RUN_AFTER_CMD="" + +REMOTE_RUN_BEFORE_CMD="" +REMOTE_RUN_AFTER_CMD="" + +## Max execution time of commands before they get force killed. Leave 0 if you don't want this to happen. Time is specified in seconds. +MAX_EXEC_TIME_PER_CMD_BEFORE=0 +MAX_EXEC_TIME_PER_CMD_AFTER=0 + +## Stops whole backup execution if one of the above commands fail +STOP_ON_CMD_ERROR=no + +## Run local and remote after backup cmd's even on failure +RUN_AFTER_CMD_ON_ERROR=yes diff --git a/dev/tests/run_tests.sh b/dev/tests/run_tests.sh index 29b0468..835792c 100755 --- a/dev/tests/run_tests.sh +++ b/dev/tests/run_tests.sh @@ -1,23 +1,15 @@ #!/usr/bin/env bash -## obackup basic tests suite 2016113001 +## obackup basic tests suite 2016122301 #TODO: Must recreate files before each test set -#TODO: Improve this by backcopying from osync tests OBACKUP_DIR="$(pwd)" OBACKUP_DIR=${OBACKUP_DIR%%/dev*} DEV_DIR="$OBACKUP_DIR/dev" TESTS_DIR="$DEV_DIR/tests" -if [ "$TRAVIS_RUN" == true ]; then - echo "Running with travis settings" - CONF_DIR="$TESTS_DIR/conf-travis" -else - echo "Running with local settings" - CONF_DIR="$TESTS_DIR/conf-local" -fi - +CONF_DIR="$TESTS_DIR/conf" LOCAL_CONF="local.conf" PULL_CONF="pull.conf" PUSH_CONF="push.conf" @@ -70,21 +62,69 @@ ROTATE_1_EXTENSION=".obackup.1" PASSFILE="passfile" CRYPT_TEST_FILE="testfile" -function SetStableToYes () { - if grep "^IS_STABLE=YES" "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" > /dev/null; then - IS_STABLE=yes - else - IS_STABLE=no - sed -i.tmp 's/^IS_STABLE=no/IS_STABLE=yes/' "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" - assertEquals "Set stable to yes" "0" $? - fi +# Later populated variables +OBACKUP_VERSION=2.x +OBACKUP_MIN_VERSION=x +OBACKUP_IS_STABLE=maybe + +# Setup an array with all function modes +#declare -Ag osyncParameters + +function GetConfFileValue () { + local file="${1}" + local name="${2}" + local value + + value=$(grep "^$name=" "$file") + if [ $? == 0 ]; then + value="${value##*=}" + echo "$value" + else + assertEquals "$name does not exist in [$file]." "1" "0" + fi } -function SetStableToOrigin () { - if [ "$IS_STABLE" == "no" ]; then - sed -i.tmp 's/^IS_STABLE=yes/IS_STABLE=no/' "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" - assertEquals "Set stable to origin value" "0" $? - fi +function SetConfFileValue () { + local file="${1}" + local name="${2}" + local value="${3}" + + if grep "^$name=" "$file" > /dev/null; then + # Using -i.tmp for BSD compat + sed -i.tmp "s/^$name=.*/$name=$value/" "$file" + rm -f "$file.tmp" + assertEquals "Set $name to [$value]." "0" $? + else + assertEquals "$name does not exist in [$file]." "1" "0" + fi +} + +function SetupSSH { + echo -e 'y\n'| ssh-keygen -t rsa -b 2048 -N "" -f "${HOME}/.ssh/id_rsa_local" + if ! grep "$(cat ${HOME}/.ssh/id_rsa_local.pub)" "${HOME}/.ssh/authorized_keys"; then + cat "${HOME}/.ssh/id_rsa_local.pub" >> "${HOME}/.ssh/authorized_keys" + fi + chmod 600 "${HOME}/.ssh/authorized_keys" + + # Add localhost to known hosts so self connect works + if [ -z "$(ssh-keygen -F localhost)" ]; then + ssh-keyscan -H localhost >> "${HOME}/.ssh/known_hosts" + fi + + # Update remote conf files with SSH port + sed -i.tmp 's#ssh://.*@localhost:[0-9]*/#ssh://'$REMOTE_USER'@localhost:'$SSH_PORT'/#' "$CONF_DIR/$PULL_CONF" + sed -i.tmp 's#ssh://.*@localhost:[0-9]*/#ssh://'$REMOTE_USER'@localhost:'$SSH_PORT'/#' "$CONF_DIR/$PUSH_CONF" +} + +function RemoveSSH { + local pubkey + + if [ -f "${HOME}/.ssh/id_rsa_local" ]; then + + pubkey=$(cat "${HOME}/.ssh/id_rsa_local.pub") + sed -i.bak "#$pubkey#d" "${HOME}/.ssh/authorized_keys" + rm -f "${HOME}/.ssh/{id_rsa_local.pub,id_rsa_local}" + fi } function SetEncryption () { @@ -146,23 +186,59 @@ EOF echo "PassPhrase123" > "$TESTS_DIR/$PASSFILE" } -function SetupSSH { - echo -e 'y\n'| ssh-keygen -t rsa -b 2048 -N "" -f "${HOME}/.ssh/id_rsa_local" - cat "${HOME}/.ssh/id_rsa_local.pub" >> "${HOME}/.ssh/authorized_keys" - chmod 600 "${HOME}/.ssh/authorized_keys" - - # Add localhost to known hosts so self connect works - if [ -z $(ssh-keygen -F localhost) ]; then - ssh-keyscan -H localhost >> ~/.ssh/known_hosts - fi -} - function oneTimeSetUp () { + START_TIME=$SECONDS + source "$DEV_DIR/ofunctions.sh" + GetLocalOS + + echo "Detected OS: $LOCAL_OS" + + # Set some travis related changes + if [ "$TRAVIS_RUN" == true ]; then + echo "Running with travis settings" + REMOTE_USER="travis" + SetConfFileValue "$CONF_DIR/$PULL_CONF" "REMOTE_3RD_PARTY_HOSTS" "" + SetConfFileValue "$CONF_DIR/$PUSH_CONF" "REMOTE_3RD_PARTY_HOSTS" "" + else + echo "Running with local settings" + REMOTE_USER="root" + SetConfFileValue "$CONF_DIR/$PULL_CONF" "REMOTE_3RD_PARTY_HOSTS" "\"www.kernel.org www.google.com\"" + SetConfFileValue "$CONF_DIR/$PUSH_CONF" "REMOTE_3RD_PARTY_HOSTS" "\"www.kernel.org www.google.com\"" + fi + + # Get default ssh port from env + if [ "$SSH_PORT" == "" ]; then + SSH_PORT=22 + fi + SetupGPG SetupSSH + + # Get OBACKUP version + OBACKUP_VERSION=$(GetConfFileValue "$OBACKUP_DIR/$OBACKUP_DEV_EXECUTABLE" "PROGRAM_VERSION") + OBACKUP_VERSION="${OBACKUP_VERSION##*=}" + OBACKUP_MIN_VERSION="${OBACKUP_VERSION:2:1}" + + OBACKUP_IS_STABLE=$(GetConfFileValue "$OBACKUP_DIR/$OBACKUP_DEV_EXECUTABLE" "IS_STABLE") + + echo "Running with $OBACKUP_VERSION ($OBACKUP_MIN_VERSION) STABLE=$OBACKUP_IS_STABLE" } +function oneTimeTearDown () { + SetConfFileValue "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" "IS_STABLE" "$OBACKUP_IS_STABLE" + + RemoveSSH + + #TODO: uncomment this when dev is done + rm -rf "$OBACKUP_TEST_DIR" + rm -f "$TMP_FILE" + + ELAPSED_TIME=$(($SECONDS - $START_TIME)) + echo "It took $ELAPSED_TIME seconds to run these tests." +} + + function setUp () { rm -rf "$SOURCE_DIR" rm -rf "$TARGET_DIR" @@ -208,17 +284,16 @@ function setUp () { ) } -function oneTimeTearDown () { - SetStableToOrigin -} - function test_Merge () { cd "$DEV_DIR" ./merge.sh assertEquals "Merging code" "0" $? - SetStableToYes + + # Set obackup version to stable while testing to avoid warning message + SetConfFileValue "$OBACKUP_DIR/$OBACKUP_EXECUTABLE" "IS_STABLE" "yes" } +# Check this for $TESTS_DIR should maybe not be this directory but $SOURCE_DIR or $DEST_DIR # Keep this function to check Travis environment GPG behavior function disabled_test_GPG () { echo "Encrypting file"