Last active
September 2, 2023 08:52
-
-
Save arkenidar/6078cd1ec6c53c81655c8a67e8310a3f to your computer and use it in GitHub Desktop.
download backup /root /etc/apache2 /var/www via rsync (and ssh)
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
#!/usr/bin/env bash | |
# env RSOPT="--dry-run" ~/Dropbox/my-www/rsync-backup-www.sh | |
# env RSOPT="--dry-run --delete" ~/Dropbox/my-www/rsync-backup-www.sh | |
HOST=arkenidar.com | |
THIS=backup-www | |
DEST="$(dirname "$BASH_SOURCE")/$THIS" | |
## DEST=~/Dropbox/my-www/$THIS # for GNU-Linux | |
## DEST=/c/opt/Dropbox/my-www/$THIS # for MSYS (MS-Windows-11) | |
mkdir --parents $DEST | |
RSEXCLUDE="--exclude .vscode-server --no-links --info=nonreg0" # --no-links --info=nonreg0 for MSYS (MS-Windows-11) | |
RSGREP=" | grep -E '^deleting|[^/]$|^$' " # https://stackoverflow.com/questions/8580873/do-not-show-directories-in-rsync-output | |
line="------------------------------------------------" | |
echo $line && \ | |
cd $DEST && RSYNC="rsync $RSOPT -arvz $RSEXCLUDE root@$HOST:" && \ | |
for dir in /root /etc/apache2 /var/www ; do | |
COMMAND="$RSYNC$dir . -- $RSGREP " && \ | |
echo ">> $COMMAND" && eval $COMMAND | |
if [ $? -ne 0 ] ; then | |
echo $line | |
echo ">> Exit status is FAILURE, exiting." | |
echo $line | |
exit 1 | |
fi && \ | |
echo $line | |
done && \ | |
echo ">> backup DONE (BUT databases aren't included)" && \ | |
echo $line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment