Created
January 16, 2014 00:30
-
-
Save alexclifford/8447577 to your computer and use it in GitHub Desktop.
Check if there are any BackupPC host backups that haven't been copied with rsync.
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 | |
PC_DIR="/var/lib/backuppc/pc" | |
REMOTE_SERVER=$1 | |
SSH_PORT=$2 | |
# SSH to a remote server to run the specified command | |
remote () { | |
ssh -p $SSH_PORT root@$REMOTE_SERVER "$@" | |
} | |
# Return true if the specified remote directory exists | |
check_exists () { | |
if remote test -d "$1" | |
then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
# Loop through all the BackupPC hosts | |
for DIR in `ls $PC_DIR/` | |
do | |
# Loop through each full and incremental backup directory for a host | |
for HOST_DIR in `ls -vd $PC_DIR/$DIR/[0-9]*/` | |
do | |
# Do a sync if a directory exists locally but not on the remote server | |
if ! check_exists "$HOST_DIR" | |
then | |
echo $HOST_DIR | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Old code I used for a while to test rsyncs before I was using @alexclifford/backuppc-sync.