diff --git a/config/rclone b/config/rclone index abeb0e5..bf0974d 100644 --- a/config/rclone +++ b/config/rclone @@ -1,4 +1,4 @@ [remote] type = drive -token = {"access_token":"ya29.GlwyB7bPoazIlbMVi1vXm6yQNZkU0W9PzO4xDYfkW6hICI05RtBHOyU4AychW6r9ucxdfPUIPTh8cdFt__dy_DzEqWJh9x1JuDNeafWVqZa6lgpoqptOPk_gOKo-NQ","token_type":"Bearer","refresh_token":"1/bCag1YzbcbjLgZEpfLZzku9l293RiEzHdVNnkdIHRSo","expiry":"2019-06-25T10:05:04.667776-06:00"} +token = {"access_token":"ya29.Glw0B6k5QQe7Z5AN4pB_fm5FRBzGHcM7qMBIC8hqfReJ4cb74quNeAhlSWyeK-LtGZsuuvAhIuwtTc9JGAgpdVdRoxH5XKSKCvxV9qPfH2UXVKYLDOE25yNXoPMSJQ","token_type":"Bearer","refresh_token":"1/bCag1YzbcbjLgZEpfLZzku9l293RiEzHdVNnkdIHRSo","expiry":"2019-06-27T08:05:32.164204805-06:00"} diff --git a/go/pkg/linux_amd64/github.com/restic/restic.a b/go/pkg/linux_amd64/github.com/restic/restic.a new file mode 100644 index 0000000..44d344a Binary files /dev/null and b/go/pkg/linux_amd64/github.com/restic/restic.a differ diff --git a/sync.sh b/sync.sh index c9a412f..dd4cbd2 100644 --- a/sync.sh +++ b/sync.sh @@ -5,7 +5,7 @@ function main() { set -u cd "$(dirname "${BASH_SOURCE[0]}")" - export GOPATH=$PWD/go + export GOPATH="$PWD/go" if [ -z "${PASSWORD:-""}" ]; then read -sp "Password: " PASSWORD @@ -27,22 +27,22 @@ function main() { } function install() { - mkdir -p $GOPATH/bin/$(uname) + mkdir -p "$GOPATH/bin/$(uname)" for i in ncw/rclone restic/restic; do local b="${i##*/}" - if [ -e $GOPATH/bin/$(uname)/$b ]; then + if [ -e "$GOPATH/bin/$(uname)/$b" ]; then continue fi - go get -u github.com/$i - pushd $GOPATH/src/github.com/$i + go get -u "github.com/$i" + pushd "$GOPATH/src/github.com/$i" case "$i" in restic* ) go run build.go - mv ./$b $GOPATH/bin/$(uname)/$b + mv "./$b" "$GOPATH/bin/$(uname)/$b" ;; * ) go install - mv $GOPATH/bin/$b $GOPATH/bin/$(uname)/$b + mv "$GOPATH/bin/$b" "$GOPATH/bin/$(uname)/$b" ;; esac popd @@ -50,8 +50,8 @@ function install() { } function configure() { - mkdir -p $PWD/config - if [ ! -e $PWD/config/rclone ]; then + mkdir -p "$PWD/config" + if [ ! -e "$PWD/config/rclone" ]; then configure_rclone fi if ! RESTIC snapshots; then @@ -71,23 +71,22 @@ function configure_rclone() { function configure_restic() { RESTIC init - touch $PWD/config/restic + touch "$PWD/config/restic" } function backup() { for arg in "$@"; do local real="$(realpath "$arg")" - if [ "$real" == "${read#$HOME/}" ]; then + if [ "$real" == "${real#$HOME/}" ]; then log "Cowardly skipping $arg ($real) for not being under \$HOME ($HOME)" continue fi - echo BACKUP $real + log "BACKUP $real" RESTIC backup \ -e "**.sw*" \ --tag "${real#$HOME/}" \ - $real + "$real" done - clean_remote } function restore() { @@ -98,14 +97,17 @@ function restore() { local latest="$(RESTIC snapshots --last | sort -k 2 | grep '20[0-9][0-9].[0-9][0-9].[0-9][0-9]' | tail -n 1)" local id="$(echo "$latest" | awk '{print $1}')" local path="$(echo "$latest" | awk '{print $5}')" - echo restore $id as $HOME/$path as $HOME/$path-restore - rm -rf $HOME/$path-{dump,restore} 2> /dev/null || true - mkdir -p $HOME/$path-dump - RESTIC restore $id --target $HOME/$path-dump - mv $HOME/$path-dump/${HOME#/}/$path $HOME/$path-restore - rm -rf $HOME/$path-{dump,old} - mv $HOME/$path $HOME/$path-old - mv $HOME/$path-restore $HOME/$path + local rpath="$(echo "$latest" | awk '{print $6}')" + log "RESTORE $id as $HOME/$path as $HOME/$path-restore" + rm -rf "$HOME/$path-"{dump,restore} 2> /dev/null || true + mkdir -p "$HOME/$path-dump" + RESTIC restore $id --target "$HOME/$path-dump" + mv "$HOME/$path-dump/${rpath#/}" "$HOME/$path-restore" + rm -rf "$HOME/$path-"{dump,old} || true + if [ -d "$HOME/$path" ]; then + mv "$HOME/$path" "$HOME/$path-old" + fi + mv "$HOME/$path-restore" "$HOME/$path" done clean_remote --prune }