Skip to content

Instantly share code, notes, and snippets.

@lopes
Last active August 7, 2024 13:33
Show Gist options
  • Save lopes/5038224 to your computer and use it in GitHub Desktop.
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
#!/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