Needs some prune but pretty gud
parent
98fcfc2bcb
commit
1e7a7da7ac
|
|
@ -0,0 +1,3 @@
|
|||
TODO
|
||||
|
||||
- pull command to get LATEST from any source, pull, extract to TARGET dir
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
[remote]
|
||||
type = drive
|
||||
token = {"access_token":"ya29.GlwxB54qvp3VZajUzFQSzVFTmHKAFLGlIVoQ504ZDFlC2GXbhQry3Wb8IvTZEGSPCrC5o8PO9yHQxZ5szPeAomkpu5zyT5o242Ae0VxZTwYAdhcK2a4OHN1eVib6VQ","token_type":"Bearer","refresh_token":"1/bCag1YzbcbjLgZEpfLZzku9l293RiEzHdVNnkdIHRSo","expiry":"2019-06-24T12:09:45.976252-06:00"}
|
||||
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"}
|
||||
|
||||
|
|
|
|||
29
sync.sh
29
sync.sh
|
|
@ -20,6 +20,7 @@ function main() {
|
|||
shift
|
||||
case "$action" in
|
||||
backup ) backup "$@" ;;
|
||||
restore ) restore "$@" ;;
|
||||
* ) RESTIC "$action" "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -52,7 +53,7 @@ function configure() {
|
|||
if [ ! -e $PWD/config/rclone ]; then
|
||||
configure_rclone
|
||||
fi
|
||||
if [ ! -e $PWD/config/restic ]; then
|
||||
if ! RESTIC snapshots; then
|
||||
configure_restic
|
||||
fi
|
||||
}
|
||||
|
|
@ -75,11 +76,35 @@ function configure_restic() {
|
|||
function backup() {
|
||||
for arg in "$@"; do
|
||||
local real="$(realpath "$arg")"
|
||||
if [ "$real" == "${read#$HOME/}" ]; then
|
||||
log "Cowardly skipping $arg ($real) for not being under \$HOME ($HOME)"
|
||||
continue
|
||||
fi
|
||||
echo BACKUP $real
|
||||
RESTIC backup \
|
||||
-e "**.sw*" \
|
||||
--tag "${real#$HOME/}" \
|
||||
$real
|
||||
RESTIC forget --keep-last 20
|
||||
RESTIC forget --keep-last 2 --group-by host,tags #--prune
|
||||
done
|
||||
}
|
||||
|
||||
function restore() {
|
||||
for arg in "$@"; do
|
||||
if [ -e "$arg" ] || [ -d "$arg" ]; then
|
||||
arg="$(realpath "$arg")"
|
||||
fi
|
||||
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
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
a
|
||||
|
|
@ -0,0 +1 @@
|
|||
b
|
||||
|
|
@ -0,0 +1 @@
|
|||
a
|
||||
|
|
@ -0,0 +1 @@
|
|||
a
|
||||
|
|
@ -0,0 +1 @@
|
|||
b
|
||||
Loading…
Reference in New Issue