Last active
August 7, 2024 13:33
-
-
Save lopes/5038224 to your computer and use it in GitHub Desktop.
Syncs backups from different servers in a single file server. #shell #shellscript #files #backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#sync-bkps.sh | |
# | |
# Syncs backups from different servers in a single | |
# place, using rsync. This "single place", in this | |
# case is a shared folder in a Windows 2008 system. | |
# So, we have to mount it using Samba first. | |
# | |
# AUTHOR.: José Lopes de Oliveira Jr. <indiecode.com.br> | |
# LICENSE: GPLv3+ | |
## | |
BKP_PATH="$HOME/Public/backups-servers" | |
# Is file server mounted? | |
while [ ! -e "$BKP_PATH" ]; do | |
read -sp "AD password for user service: " pass | |
sudo mount -t smbfs \ | |
-o username=service,password="$pass",uid=1000,gid=1000 \ | |
//10.0.1.2/files \ | |
"$HOME/Public" | |
done | |
echo # Next line, please. | |
# Sync backups. | |
echo "PIRANHA"; rsync -avz [email protected]:/var/local/piranha \ | |
--delete-after \ | |
"$BKP_PATH" | |
echo "TRAIRA"; rsync -e "ssh -p 2222" \ | |
-avz [email protected]:/var/local/traira \ | |
--delete-after \ | |
"$BKP_PATH" | |
echo "AGULHA"; rsync -e "ssh -p 2222" \ | |
-avz [email protected]:/var/local/agulha \ | |
--delete-after \ | |
"$BKP_PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment