damnit
parent
ffd988c714
commit
2cde5fbb38
|
|
@ -1,4 +1,4 @@
|
||||||
[remote]
|
[remote]
|
||||||
type = drive
|
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"}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
46
sync.sh
46
sync.sh
|
|
@ -5,7 +5,7 @@ function main() {
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
export GOPATH=$PWD/go
|
export GOPATH="$PWD/go"
|
||||||
|
|
||||||
if [ -z "${PASSWORD:-""}" ]; then
|
if [ -z "${PASSWORD:-""}" ]; then
|
||||||
read -sp "Password: " PASSWORD
|
read -sp "Password: " PASSWORD
|
||||||
|
|
@ -27,22 +27,22 @@ function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
mkdir -p $GOPATH/bin/$(uname)
|
mkdir -p "$GOPATH/bin/$(uname)"
|
||||||
for i in ncw/rclone restic/restic; do
|
for i in ncw/rclone restic/restic; do
|
||||||
local b="${i##*/}"
|
local b="${i##*/}"
|
||||||
if [ -e $GOPATH/bin/$(uname)/$b ]; then
|
if [ -e "$GOPATH/bin/$(uname)/$b" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
go get -u github.com/$i
|
go get -u "github.com/$i"
|
||||||
pushd $GOPATH/src/github.com/$i
|
pushd "$GOPATH/src/github.com/$i"
|
||||||
case "$i" in
|
case "$i" in
|
||||||
restic* )
|
restic* )
|
||||||
go run build.go
|
go run build.go
|
||||||
mv ./$b $GOPATH/bin/$(uname)/$b
|
mv "./$b" "$GOPATH/bin/$(uname)/$b"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
go install
|
go install
|
||||||
mv $GOPATH/bin/$b $GOPATH/bin/$(uname)/$b
|
mv "$GOPATH/bin/$b" "$GOPATH/bin/$(uname)/$b"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
popd
|
popd
|
||||||
|
|
@ -50,8 +50,8 @@ function install() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure() {
|
function configure() {
|
||||||
mkdir -p $PWD/config
|
mkdir -p "$PWD/config"
|
||||||
if [ ! -e $PWD/config/rclone ]; then
|
if [ ! -e "$PWD/config/rclone" ]; then
|
||||||
configure_rclone
|
configure_rclone
|
||||||
fi
|
fi
|
||||||
if ! RESTIC snapshots; then
|
if ! RESTIC snapshots; then
|
||||||
|
|
@ -71,23 +71,22 @@ function configure_rclone() {
|
||||||
|
|
||||||
function configure_restic() {
|
function configure_restic() {
|
||||||
RESTIC init
|
RESTIC init
|
||||||
touch $PWD/config/restic
|
touch "$PWD/config/restic"
|
||||||
}
|
}
|
||||||
|
|
||||||
function backup() {
|
function backup() {
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
local real="$(realpath "$arg")"
|
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)"
|
log "Cowardly skipping $arg ($real) for not being under \$HOME ($HOME)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo BACKUP $real
|
log "BACKUP $real"
|
||||||
RESTIC backup \
|
RESTIC backup \
|
||||||
-e "**.sw*" \
|
-e "**.sw*" \
|
||||||
--tag "${real#$HOME/}" \
|
--tag "${real#$HOME/}" \
|
||||||
$real
|
"$real"
|
||||||
done
|
done
|
||||||
clean_remote
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore() {
|
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 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 id="$(echo "$latest" | awk '{print $1}')"
|
||||||
local path="$(echo "$latest" | awk '{print $5}')"
|
local path="$(echo "$latest" | awk '{print $5}')"
|
||||||
echo restore $id as $HOME/$path as $HOME/$path-restore
|
local rpath="$(echo "$latest" | awk '{print $6}')"
|
||||||
rm -rf $HOME/$path-{dump,restore} 2> /dev/null || true
|
log "RESTORE $id as $HOME/$path as $HOME/$path-restore"
|
||||||
mkdir -p $HOME/$path-dump
|
rm -rf "$HOME/$path-"{dump,restore} 2> /dev/null || true
|
||||||
RESTIC restore $id --target $HOME/$path-dump
|
mkdir -p "$HOME/$path-dump"
|
||||||
mv $HOME/$path-dump/${HOME#/}/$path $HOME/$path-restore
|
RESTIC restore $id --target "$HOME/$path-dump"
|
||||||
rm -rf $HOME/$path-{dump,old}
|
mv "$HOME/$path-dump/${rpath#/}" "$HOME/$path-restore"
|
||||||
mv $HOME/$path $HOME/$path-old
|
rm -rf "$HOME/$path-"{dump,old} || true
|
||||||
mv $HOME/$path-restore $HOME/$path
|
if [ -d "$HOME/$path" ]; then
|
||||||
|
mv "$HOME/$path" "$HOME/$path-old"
|
||||||
|
fi
|
||||||
|
mv "$HOME/$path-restore" "$HOME/$path"
|
||||||
done
|
done
|
||||||
clean_remote --prune
|
clean_remote --prune
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue