Created
July 16, 2013 17:16
-
-
Save joelkallman/6010668 to your computer and use it in GitHub Desktop.
Recursive Directory File Transfer
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 | |
# 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