2021-12-28 02:54:26 -06:00
#!/bin/sh
2021-11-27 19:30:34 -06:00
2021-12-02 13:32:27 -06:00
# This script backs up some important stuff
2021-11-27 19:30:34 -06:00
2022-10-04 21:44:51 -05:00
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
2022-07-31 19:03:32 -05:00
# Run only one instance of this script at one time
2022-08-01 21:47:07 -05:00
[ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/impfilesbk.lock" "$0" "$@" || :
2022-07-31 19:03:32 -05:00
2022-06-15 01:46:58 -05:00
# Setup location for home and backup directory
2022-07-29 21:50:49 -05:00
HMDIR="/home/sintan"
BKDIR="/mnt/storage/sintan"
2021-12-02 13:32:27 -06:00
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Backing up Documents..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-11-11 00:50:40 -06:00
rsync -aAXH --delete --stats --exclude '*Rust/*/target/' "$HMDIR/Documents/" "$BKDIR/Documents/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2021-11-27 19:30:34 -06:00
2022-07-29 21:50:49 -05:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2021-12-17 22:09:50 -06:00
2023-07-16 18:23:00 -05:00
echo $(date) "| Backing up Academics..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-29 21:50:49 -05:00
rsync -aAXH --delete --stats "$HMDIR/Academics/" "$BKDIR/Academics/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2022-07-29 21:50:49 -05:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2023-07-16 18:23:00 -05:00
echo $(date) "| Backing up Pictures..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-29 21:50:49 -05:00
rsync -aAXH --delete --stats "$HMDIR/Pictures/" "$BKDIR/Pictures/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2022-07-29 21:50:49 -05:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2022-09-17 22:09:28 -05:00
# echo `date` "| Backing up PhotoPrism index..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
# rsync -aAXH --delete --stats "$HMDIR/PhotoPrism/storage/index-backup.sql" "$BKDIR/Programs/photoprism-backup.sql" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
# echo $'\n'`date` "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-20 18:31:02 -05:00
2022-09-17 22:09:28 -05:00
# echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-20 18:31:02 -05:00
2023-07-16 18:23:00 -05:00
echo $(date) "| Backing up Zotero..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-29 21:50:49 -05:00
rsync -aAXH --delete --stats "$HMDIR/Zotero/" "$BKDIR/Zotero/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2022-07-29 21:50:49 -05:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-20 03:32:32 -05:00
2023-07-16 18:23:00 -05:00
echo $(date) "| Backing up some dotfiles..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-25 02:20:41 -05:00
rsync -aAXH --delete --stats --quiet --no-links --exclude={'*cache*','*Cache*','*autosave*','chromium','Code','Code - OSS','discord','vivaldi','Ferdium/Partitions'} \
2023-07-16 18:23:00 -05:00
--delete-excluded "$HMDIR/.config/" "$BKDIR/dotfiles/[dot]config/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-31 16:29:17 -05:00
rsync -aAXH --delete --stats "$HMDIR/.profile" "$BKDIR/dotfiles/[dot]profile" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/.bashrc" "$BKDIR/dotfiles/[dot]bashrc" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/.Xresources" "$BKDIR/dotfiles/[dot]Xresources" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/.local/bin/personal/" "$BKDIR/dotfiles/[dot]local_bin_personal/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/.ssh/" "$BKDIR/dotfiles/[dot]ssh/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-06-15 01:31:38 -05:00
2022-07-29 21:50:49 -05:00
echo $'\n'"--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
echo "NOW SYNCING UP WITH THE SERVER" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-29 21:50:49 -05:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
HMDIR="/mnt/storage/sintan"
2022-09-17 22:13:17 -05:00
BKDIR="server-rsync:/mnt/storage"
2022-09-17 22:09:28 -05:00
LGDIR="/home/sintan"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling pkglists_server to HDD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$BKDIR/Documents/Backup/pkglists_server/" "$HMDIR/Documents/Backup/pkglists_server/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling pkglists_server to SSD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:55:55 -05:00
rsync -aAXH --delete --stats "$HMDIR/Documents/Backup/pkglists_server/" "$LGDIR/Documents/Backup/pkglists_server/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing the rest of Documents to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-10-06 23:55:04 -05:00
rsync -aAXH --delete --stats --exclude="Backup/pkglists_server" "$HMDIR/Documents/" "$BKDIR/Documents/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing Academics to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$HMDIR/Academics/" "$BKDIR/Academics/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing Pictures to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats --no-links "$HMDIR/Pictures/" "$BKDIR/Pictures/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing Zotero to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$HMDIR/Zotero/" "$BKDIR/Zotero/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing dotfiles to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$HMDIR/dotfiles/" "$BKDIR/dotfiles/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling dotfiles_server to HDD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$BKDIR/dotfiles_server/" "$HMDIR/dotfiles_server/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling Docker related backups to HDD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$BKDIR/Programs/Docker/" "$HMDIR/Programs/Docker/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling server installer_scripts to HDD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$BKDIR/Programs/installer-scripts/" "$HMDIR/Programs/installer-scripts/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing the rest of Programs to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-10-02 00:15:29 -05:00
rsync -aAXH --delete --stats --exclude={"Docker","installer-scripts"} "$HMDIR/Programs/" "$BKDIR/Programs/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pulling important Movies to HDD..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$BKDIR/Movies/" "$HMDIR/Movies/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing Music to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$HMDIR/Music/" "$BKDIR/Music/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $(date) "| Pushing Videos to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
rsync -aAXH --delete --stats "$HMDIR/Videos/" "$BKDIR/Videos/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2023-07-16 18:23:00 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-12-14 18:19:48 -06:00
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
2022-09-17 22:09:28 -05:00
echo $'\n'"--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"