commit
637336a45d
2 changed files with 44 additions and 2 deletions
14
README.md
14
README.md
|
|
@ -151,6 +151,10 @@ For the [Google Cloud Storage](https://cloud.google.com/storage/) storage backen
|
||||||
-b, --backup runs an incremental backup
|
-b, --backup runs an incremental backup
|
||||||
-f, --full forces a full backup
|
-f, --full forces a full backup
|
||||||
-v, --verify verifies the backup
|
-v, --verify verifies the backup
|
||||||
|
-e, --cleanup cleanup the backup (eg. broken sessions), by default using
|
||||||
|
duplicity --force flag, use --dry-run to actually log what
|
||||||
|
will be cleaned up without removing (see man duplicity
|
||||||
|
> ACTIONS > cleanup for details)
|
||||||
-l, --list-current-files lists the files currently backed up in the archive
|
-l, --list-current-files lists the files currently backed up in the archive
|
||||||
-s, --collection-status show all the backup sets in the archive
|
-s, --collection-status show all the backup sets in the archive
|
||||||
|
|
||||||
|
|
@ -220,15 +224,23 @@ Note that the commands `--restore-file` and `--restore-dir` are equivalent.
|
||||||
|
|
||||||
duplicity-backup.sh [-c config_file] --verify
|
duplicity-backup.sh [-c config_file] --verify
|
||||||
|
|
||||||
|
**Clean the backup**
|
||||||
|
|
||||||
|
duplicity-backup.sh [-c config_file] --cleanup
|
||||||
|
|
||||||
**Backup the script and gpg key in a encrypted tarfile (for safekeeping)**
|
**Backup the script and gpg key in a encrypted tarfile (for safekeeping)**
|
||||||
|
|
||||||
duplicity-backup.sh [-c config_file] --backup-script
|
duplicity-backup.sh [-c config_file] --backup-script
|
||||||
|
|
||||||
|
|
||||||
## Cron Usage Example
|
## Cron Usage Example (backup)
|
||||||
|
|
||||||
41 3 * * * /absolute/path/to/duplicity-backup.sh -c /etc/duplicity-backup.conf -b
|
41 3 * * * /absolute/path/to/duplicity-backup.sh -c /etc/duplicity-backup.conf -b
|
||||||
|
|
||||||
|
## Cron Usage Example (cleanup)
|
||||||
|
|
||||||
|
41 4 * * 1 /absolute/path/to/duplicity-backup.sh -c /etc/duplicity-backup.conf -e
|
||||||
|
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ echo "USAGE:
|
||||||
-b, --backup runs an incremental backup
|
-b, --backup runs an incremental backup
|
||||||
-f, --full forces a full backup
|
-f, --full forces a full backup
|
||||||
-v, --verify verifies the backup
|
-v, --verify verifies the backup
|
||||||
|
-e, --cleanup cleanup the backup (eg. broken sessions), by default using
|
||||||
|
duplicity --force flag, use --dry-run to actually log what
|
||||||
|
will be cleaned up without removing (see man duplicity
|
||||||
|
> ACTIONS > cleanup for details)
|
||||||
-l, --list-current-files lists the files currently backed up in the archive
|
-l, --list-current-files lists the files currently backed up in the archive
|
||||||
-s, --collection-status show all the backup sets in the archive
|
-s, --collection-status show all the backup sets in the archive
|
||||||
|
|
||||||
|
|
@ -83,7 +87,7 @@ echo "USAGE:
|
||||||
# Some expensive argument parsing that allows the script to
|
# Some expensive argument parsing that allows the script to
|
||||||
# be insensitive to the order of appearance of the options
|
# be insensitive to the order of appearance of the options
|
||||||
# and to handle correctly option parameters that are optional
|
# and to handle correctly option parameters that are optional
|
||||||
while getopts ":c:t:bfvlsnd-:" opt; do
|
while getopts ":c:t:bfvelsnd-:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
# parse long options (a bit tricky because builtin getopts does not
|
# parse long options (a bit tricky because builtin getopts does not
|
||||||
# manage long options and I don't want to impose GNU getopt dependancy)
|
# manage long options and I don't want to impose GNU getopt dependancy)
|
||||||
|
|
@ -146,6 +150,7 @@ while getopts ":c:t:bfvlsnd-:" opt; do
|
||||||
b) COMMAND="backup";;
|
b) COMMAND="backup";;
|
||||||
f) COMMAND="full";;
|
f) COMMAND="full";;
|
||||||
v) COMMAND="verify";;
|
v) COMMAND="verify";;
|
||||||
|
e) COMMAND="cleanup";;
|
||||||
l) COMMAND="list-current-files";;
|
l) COMMAND="list-current-files";;
|
||||||
s) COMMAND="collection-status";;
|
s) COMMAND="collection-status";;
|
||||||
n) DRY_RUN="--dry-run ";; # dry run
|
n) DRY_RUN="--dry-run ";; # dry run
|
||||||
|
|
@ -631,6 +636,17 @@ duplicity_backup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duplicity_cleanup_failed()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
eval "${ECHO}" "${DUPLICITY}" "${OPTION}" "${VERBOSITY}" "${STATIC_OPTIONS}" \
|
||||||
|
"${DEST}" \
|
||||||
|
>> "${LOGFILE}"
|
||||||
|
} || {
|
||||||
|
BACKUP_ERROR=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setup_passphrase()
|
setup_passphrase()
|
||||||
{
|
{
|
||||||
if [ ! -z "${GPG_ENC_KEY}" -a ! -z "${GPG_SIGN_KEY}" -a "${GPG_ENC_KEY}" != "${GPG_SIGN_KEY}" ]; then
|
if [ ! -z "${GPG_ENC_KEY}" -a ! -z "${GPG_SIGN_KEY}" -a "${GPG_ENC_KEY}" != "${GPG_SIGN_KEY}" ]; then
|
||||||
|
|
@ -790,6 +806,20 @@ case "${COMMAND}" in
|
||||||
echo -e "Verify complete. Check the log file for results:\n>> ${LOGFILE}"
|
echo -e "Verify complete. Check the log file for results:\n>> ${LOGFILE}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"cleanup")
|
||||||
|
OPTION="cleanup"
|
||||||
|
|
||||||
|
if [ -z "${DRY_RUN}" ]; then
|
||||||
|
STATIC_OPTIONS="--force"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "-------[ Cleaning up Destination ]-------\n" >> "${LOGFILE}"
|
||||||
|
setup_passphrase
|
||||||
|
duplicity_cleanup_failed
|
||||||
|
|
||||||
|
echo -e "Cleanup complete." >> "${LOGFILE}"
|
||||||
|
;;
|
||||||
|
|
||||||
"restore")
|
"restore")
|
||||||
ROOT=${DEST}
|
ROOT=${DEST}
|
||||||
OPTION="restore"
|
OPTION="restore"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue