-
-
Save 1gor/9f9355b93fd5d98e7569437c5c0ac316 to your computer and use it in GitHub Desktop.
Backup with duplicity to yandex.disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Duplicity wrapper | |
# | |
# add to crontab: | |
# 0 0 * * * /bin/sh /usr/local/sbin/backup-host.sh | |
set -e | |
PASSPHRASE="long_passphrase" | |
DISK_USER="[email protected]" | |
DISK_PASSWORD="" | |
BACKUP_DIR=/ | |
INCLUDES_EXCLUDES="\ | |
--exclude '/home/*/Downloads' \ | |
--exclude '/home/*/.cache' \ | |
--exclude '/home/*/tmp' \ | |
--exclude '/home/*/VirtualBox VMs' \ | |
--exclude '/home/*/mnt' \ | |
--exclude '/root/.cache' \ | |
--exclude '/root/tmp' \ | |
--include '/home' \ | |
--include '/root' \ | |
--include '/etc' \ | |
--include '/srv' \ | |
--include '/var' \ | |
--exclude '**'" | |
DEST=webdavs://${DISK_USER}@webdav.yandex.ru/Backup/$(hostname) | |
export PASSPHRASE | |
export FTP_PASSWORD=${DISK_PASSWORD} | |
DUPLICITY_CMD="duplicity \ | |
-v2 \ | |
--ssl-cacert-file /etc/ssl/certs/ca-certificates.crt" | |
CLEAN_CMD="${DUPLICITY_CMD} \ | |
remove-older-than 2M --force \ | |
${DEST}" | |
BACKUP_CMD="${DUPLICITY_CMD} \ | |
--full-if-older-than 1M \ | |
${INCLUDES_EXCLUDES} \ | |
${BACKUP_DIR} \ | |
${DEST}" | |
VERIFY_CMD="${DUPLICITY_CMD} \ | |
verify \ | |
${INCLUDES_EXCLUDES} \ | |
${DEST} \ | |
${BACKUP_DIR}" | |
RESTORE_CMD="${DUPLICITY_CMD} \ | |
${DEST} \ | |
${PWD}" | |
echo ${CLEAN_CMD}; eval ${CLEAN_CMD} | |
echo ${BACKUP_CMD}; eval ${BACKUP_CMD} | |
echo ${VERIFY_CMD}; eval ${VERIFY_CMD} | |
# echo ${RESTORE_CMD}; eval ${RESTORE_CMD} | |
unset PASSPHRASE | |
unset FTP_PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment