From 18ec9d907f72d95b0eeb255e9b5f35242f2a4d60 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Thu, 29 Apr 2021 09:04:46 -0500 Subject: duplicity backup scripts --- .gitignore | 2 ++ bin/backup | 27 +++++++++++++++++++++++++++ deploy.sh | 19 +++++++++++++++++++ local/duplicity-config | 4 ++++ local/duplicity-excludes | 5 +++++ 5 files changed, 57 insertions(+) create mode 100755 bin/backup create mode 100644 local/duplicity-config create mode 100644 local/duplicity-excludes diff --git a/.gitignore b/.gitignore index bdd02a0..693fcde 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ vim/ dotfiles-backup config/zsh/00-local.zsh config/git/config-local +config/duplicity/config +config/duplicity/excludes diff --git a/bin/backup b/bin/backup new file mode 100755 index 0000000..9366322 --- /dev/null +++ b/bin/backup @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euo pipefail + +set -o allexport +# shellcheck source=../local/duplicity-config +source ~/.config/duplicity/config +set +o allexport + +source_directory=~ +excludes=~/.config/duplicity/excludes +target_url=b2://"$B2_KEY_ID"@"$B2_BUCKET" + +# take a new full backup every month, incremental otherwise +duplicity --full-if-older-than 1M --exclude-filelist "$excludes" "$source_directory" "$target_url" + +# keep 12 months of full backups +duplicity remove-all-but-n-full 12 --force "$target_url" + +# keep 3 months of incremental backups +duplicity remove-all-inc-of-but-n-full 3 --force "$target_url" + +# cleanup +duplicity cleanup --force "$target_url" + +# show collection status +duplicity collection-status "$target_url" diff --git a/deploy.sh b/deploy.sh index 97ce529..f8b2f32 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,6 +11,8 @@ xcache="${XDG_CACHE_HOME:-${HOME}/.cache}" xdata="${XDG_DATA_HOME:-${HOME}/.local/share}" xconfig="${XDG_CONFIG_HOME:-${HOME}/.config}" +userbin="$HOME/bin" + # deploy to XDG dirs mkdir -p "${xcache}/zsh" mkdir -p "${xdata}/zsh" @@ -36,6 +38,17 @@ do done cd .. +# deploy to user binaries +cd bin +for f in * +do + if [ -e "$userbin/${f}" ]; then + mv "$userbin/${f}" "../dotfiles-backup/${f}" + fi + ln -sf "$(pwd)/${f}" "$userbin/${f}" +done +cd .. + # install vundle for vim if [ ! -d ~/.vim/bundle/vundle ]; then git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle @@ -58,3 +71,9 @@ if [ ! -e ~/.local/share/fonts/sourcecodepro-nerd ]; then unzip local/SourceCodePro.zip -d ~/.local/share/fonts/sourcecodepro-nerd echo "Run \'fc-cache -v\' to rebuild your font cache" fi +if [ ! -e ~/.config/duplicity/config ]; then + cp local/duplicity-config ~/.config/duplicity/config +fi +if [ ! -e ~/.config/duplicity/excludes ]; then + cp local/duplicity-excludes ~/.config/duplicity/excludes +fi diff --git a/local/duplicity-config b/local/duplicity-config new file mode 100644 index 0000000..f9607b0 --- /dev/null +++ b/local/duplicity-config @@ -0,0 +1,4 @@ +PASSPHRASE= +FTP_PASSWORD= +B2_KEY_ID= +B2_BUCKET= diff --git a/local/duplicity-excludes b/local/duplicity-excludes new file mode 100644 index 0000000..122b565 --- /dev/null +++ b/local/duplicity-excludes @@ -0,0 +1,5 @@ +/home/matt/Downloads +/home/matt/.local +/home/matt/.cache +/home/matt/.mozilla +/home/matt/.wine -- cgit v1.2.3