Skip to content

Instantly share code, notes, and snippets.

@jeanatcismet
Created March 12, 2019 17:57
Show Gist options
  • Save jeanatcismet/784a733ca4fde684a942a9b166c5ce8e to your computer and use it in GitHub Desktop.
Save jeanatcismet/784a733ca4fde684a942a9b166c5ce8e to your computer and use it in GitHub Desktop.
dry-run of rotate-backups and transforming result into commands for manual removal of file via rclone_mount
#!/bin/sh
RCLONE_CONF=$(pwd)/rclone.conf
RCLONE_SRC=gdrive:/cismet/backups/
ROTATE_BACKUPS_PATH="*"
ROTATE_BACKUPS_OPTIONS="--dry-run --daily=10 --weekly=5 --monthly=13 --yearly=5"
# ===
DATA=$(pwd)/data
USER=backup
FILES=$(docker run -t --rm \
-e PUID=$(id -u $USER) \
-e PGID=$(id -g $USER) \
-v $RCLONE_CONF:/home/.rclone.conf \
--device /dev/fuse \
--privileged \
cismet/rclone-rotate-backups \
"$RCLONE_SRC" "$ROTATE_BACKUPS_PATH" "$ROTATE_BACKUPS_OPTIONS" | grep Deleting | awk '{print $7}')
RCLONE_MOUNT=backups
MOUNT_RCLONE_GIST=https://gist.github.com/jeanatcismet/096ecafc0cdabf163e8e0257a31ea7eb#file-mount_rclone-sh
echo "# mount_rlcone.sh => $MOUNT_RCLONE_GIST"
echo "mkdir -p $RCLONE_MOUNT && ./mount_rclone.sh \$(pwd)/rclone.conf $RCLONE_SRC \$(pwd)/$RCLONE_MOUNT"
echo "# paste in another console => "
for FILE in $FILES; do
echo rm ./$RCLONE_MOUNT/${FILE##"~/mnt/"}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment