FTP BACKUP - backup your postgresql database and FTP to another server

posted Sep 17, 2010, 3:17 PM by Sachchida Ojha

#!/bin/bash
FTP_SRVR=10.0.101.103 #or ip
FTP_USR=guest
FTP_PWD=guest
currdir="`pwd`";
database="testdb"
BackupFileName="emdb"
echo This script will create a database backup file and transfers file to user defined FTP location . Continue [Y/N] ?
read -t 30 YN
YN=${YN:-"Y"};
YN=${YN%%[^YyNn]*};
if ( test -z "$YN" )
then
 echo -e "Please enter either \"Y\" or \"N\" ";
eval "$0" "$@";
exit;
fi
if ( test "$YN" = "N" -o "$YN" = "n" )
then
 exit;
fi

today=`date %y%m%d%H%M%S`
rm -Rf *.dump
echo backing up em_db database. Please Wait......
pg_dump -U postgres testdb>${BackupFileName}-$today.dump
echo Done!

 

echo File FTP in progress...........
ftp -vin FTP_SRVR<<!
user $FTP_USR $FTP_PWD
binary
put *.dump
bye
EOF

Comments