Skip to content

Instantly share code, notes, and snippets.

@ylxdzsw
Last active March 19, 2020 07:57
Show Gist options
  • Save ylxdzsw/de3f0e7323e7898e6c433c419c51dbc3 to your computer and use it in GitHub Desktop.
Save ylxdzsw/de3f0e7323e7898e6c433c419c51dbc3 to your computer and use it in GitHub Desktop.
#!/usr/bin/pkexec /usr/bin/zsh
set -x
# clean up before backing up
pacman -Sc
journalctl --vacuum-time=7d
rm /var/lib/systemd/coredump/*
# backup based on last previous one to save disk space
TARGET=/run/media/ylxdzsw/DATA
NOW=$(date +%y-%m-%d)
LAST=$(tail -n 1 <(sort <(ls $TARGET)))
EX=("/dev/*" "/proc/*" "/sys/*" "/tmp/*" "/run/*" "/mnt/*" /home/ylxdzsw/.cache)
rsync -aAX --info=progress2 --exclude=$^EX --link-dest="$TARGET/$LAST" / "$TARGET/$NOW"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment