Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup with duplicity to yandex.disk
#!/bin/sh
# Duplicity wrapper
#
# Not working for now. Yandex prevents uploading lagre files via webdav.
# add to crontab:
# 0 0 * * * /bin/sh /usr/local/sbin/backup-host.sh
set -e
PASSPHRASE="long_passphrase"
DISK_USER="login@yandex.ru"
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