Skip to content

Instantly share code, notes, and snippets.

@alexclifford
Created January 16, 2014 00:30
Show Gist options
  • Save alexclifford/8447577 to your computer and use it in GitHub Desktop.
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.
#!/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
@alexclifford
Copy link
Author

Old code I used for a while to test rsyncs before I was using @alexclifford/backuppc-sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment