Created
January 18, 2013 13:34
-
-
Save theand/4564556 to your computer and use it in GitHub Desktop.
#BASH execute remote script, fetch archive, delete old archive
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 | |
eval `ssh-agent` | |
keychain id_dsa | |
. /root/.keychain/localhost-sh | |
remote_dir="/backup/mysql_sql_backup" | |
local_dir="/backup/mysql_sql_backup" | |
/usr/bin/ssh root@remote.server "/root/mysql_sql_back.sh" | |
/usr/bin/scp root@remote.server:$remote_dir/latest_sql_backup.tar.gz "$local_dir/mysql_sql.$(date +%Y%m%d).tar.gz" | |
let "i = 0" | |
for fname in $(ls -t $local_dir) | |
do | |
let "i = i + 1" | |
if [ $i -ge "80" ]; then | |
if [ -f $local_dir/$fname ]; then | |
echo "Deleting - $fname" | |
rm -f $local_dir/$fname | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment