[SLUG] Bash Scripts
Mark Feather
akwe-xavante at firenet.uk.com
Thu Apr 17 19:27:00 BST 2003
New improved Bash Script!
Thoughts and ideas please especially regarding the problem of establishing
a remote ftp connection and file transfer without user input.
####Script Begins####
#!/bin/bash
#backup of all web content
#backup of customised configuration files & other important files
#initiate file transfer to remote computer
echo
echo Creating New Backup!
cd /
echo
echo Creating Temporary Directories
mkdir -p temp.dir/config.files
echo
echo -n "Do you wish to backup the FTP Directories?....y or n: "
read one
echo
echo -n "Do you wish to backup the Servers Web Directories?....y or n: "
read two
echo
echo -n "Do you wish to backup your Configuration files?....y or n: "
read three
echo
if [ $one = "y" ]; then
echo Backing up and Zipping FTP Directories
cd /usr/local
tar -czf ftp-$(date +%d.%m.%y).tgz ftp
mv *.tgz /temp.dir
echo
fi
if [ $two = "y" ]; then
echo Backing up and Zipping the Servers Web Directories
cd /usr/local
tar -czf httpd-$(date +%d.%m.%y).tgz httpd
mv *.tgz /temp.dir
echo
fi
if [ $three = "y" ]; then
echo Backing up and Zipping Configuration files
cd /
cp /etc/profile.local /temp.dir/config.files
cp /sbin/backup01 /temp.dir/config.files
cp /sbin/backup02 /temp.dir/config.files
cp /sbin/create01 /temp.dir/config.files
cp /home/feather/.alias /temp.dir/config.files
cp /etc/proftpd.conf /temp.dir/config.files
cp /etc/hosts.allow /temp.dir/config.files
cp /etc/hosts.deny /temp.dir/config.files
cp /etc/httpd/httpd.conf /temp.dir/config.files
cd /temp.dir
tar -czf configs-$(date +%d.%m.%y).tgz config.files
rm -r config.files
echo
fi
echo
echo Moving Backed up Files
cd /
mv temp.dir /home/feather/backup.$(date +%d.%m.%y)
chown feather /home/feather/backup.$(date +%d.%m.%y)
chown feather /home/feather/backup.$(date +%d.%m.%y)/*.tgz
chmod 770 /home/feather/backup.$(date +%d.%m.%y)
chmod 770 /home/feather/backup.$(date +%d.%m.%y)/*.tgz
echo
echo Backup ready for Remote Transfer, establishing remote connection
cd /home/feather
ftp 'username'@'RemoteIpAddress'
# manual entry of Password and file transfer required, haven't #
# worked out how to write this into the script yet, i can #
# do it in a Windows script file but not Linux!!
#
echo
echo Remote Connection Closed, Backup and File transfer Complete
echo
####End of Script####
Mark
More information about the Scarborough
mailing list