Skip to content

Instantly share code, notes, and snippets.

@joelkallman
Created July 16, 2013 17:16
Show Gist options
  • Save joelkallman/6010668 to your computer and use it in GitHub Desktop.
Save joelkallman/6010668 to your computer and use it in GitHub Desktop.
Recursive Directory File Transfer
#!/bin/bash
# Edit these vars for transfer process
HOST="user@host-or-ip"
LOCALDIR="/var/backups/database"
REMOTEDIR="/path/to/base-dir"
MVDIR="/var/moved-backups/database"
# Transfer Files to external server
scp -P 22 -r $LOCALDIR $HOST":"$REMOTEDIR
if [ "$(ls -A $LOCALDIR)" ]; then
mv $LOCALDIR/* $MVDIR
echo -e "Transfer Backups Across Servers ... Moved files to /var/moved-backups/database \n"
else
echo "$LOCALDIR is Empty \n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment