1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-26 13:18:35 -06:00
random/impfilesbk

174 lines
11 KiB
Text
Raw Normal View History

2021-12-28 02:54:26 -06:00
#!/bin/sh
2021-12-02 13:32:27 -06:00
# This script backs up some important stuff
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
# 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-06-15 01:46:58 -05:00
# Setup location for home and backup directory
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"
echo $(date) "| Backing up Documents..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2024-05-23 23:00:52 -05:00
rsync -aAXH --delete --stats "$HMDIR/Documents/" "$BKDIR/Documents/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2021-12-17 22:09:50 -06:00
echo $(date) "| Backing up Academics..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/Academics/" "$BKDIR/Academics/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
2024-05-23 22:56:19 -05:00
echo $(date) "| Backing up Code..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats --exclude '*/*/target/' --exclude 'git/*/lake-packages/' \
--exclude 'git/*/build/' "$HMDIR/Code/" "$BKDIR/Code/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2024-05-23 22:56:19 -05:00
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo $(date) "| Backing up Pictures..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/Pictures/" "$BKDIR/Pictures/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06: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
echo $(date) "| Backing up Zotero..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/Zotero/" "$BKDIR/Zotero/" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-01-13 12:04:50 -06:00
echo "--------------------------------------------------" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-07-20 03:32:32 -05:00
echo $(date) "| Backing up some dotfiles..." | tee -a "$HMDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats --quiet --no-links --exclude={'*cache*','*Cache*','*autosave*','chromium','Code','Code - OSS','discord','vivaldi','Ferdium/Partitions'} \
--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"
echo $'\n'$(date) "| Done!" | tee -a "$HMDIR/TempStorage/impfilesbk.log"
2022-06-15 01:31:38 -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"
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"
if ! $(ping server-ts -nqc 1 -W 1 >/dev/null 2>&1); then
echo "Remote machine not available. Exiting..."
exit 1
fi
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"
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"
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"
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"
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"
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"
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"
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"
2024-05-23 22:56:19 -05:00
echo $(date) "| Pushing Code to server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$HMDIR/Code/" "$BKDIR/Code/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
echo $'\n'$(date) "| Done!" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
echo "--------------------------------------------------" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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"
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-10-18 17:43:44 -05:00
echo $(date) "| Pulling Music from server..." | tee -a "$LGDIR/TempStorage/impfilesbk.log"
rsync -aAXH --delete --stats "$BKDIR/Music/" "$HMDIR/Music/" | tee -a "$LGDIR/TempStorage/impfilesbk.log"
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"
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"
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"