- 论坛徽章:
- 0
|
一个简单的而实用的备份脚本,希望对大家有帮助.
#!/bin/sh
# This script edit by linuxchen<linuxbady@gmail.com>
linuxchen=$(date +%Y%m%d)
if !(test -d /root/backup/)
then
mkdir /root/backup/
fi
if !(test -f /root/backup/addip.sh."$linuxchen";/root/backup/nat.sh."$linuxchen";/root/backup/forward."$linuxchen")
then
cp /root/addip.sh /root/backup/addip.sh."$linuxchen"
cp /root/nat.sh /root/backup/nat.sh."$linuxchen"
cp /root/forward.sh /root/backup/forward."$linuxchen"
else
rm -fr /root/backup/*."$linuxchen"
cp /root/addip.sh /root/backup/addip.sh."$linuxchen"
cp /root/nat.sh /root/backup/nat.sh."$linuxchen"
cp /root/forward.sh /root/backup/forward."$linuxchen"
fi
if !(test -f /root/backup/addip.sh."$linuxchen";/root/backup/nat.sh."$linuxchen";/root/backup/forward."$linuxchen")
then
echo "backup is fales!"
else echo "backup is successfull!"
fi
# backup to ftp server
host=172.18.8.11
username=linuxchen1
passwd=linuxchen1
if !(test -d /backup)
then
mkdir /backup
fi
backup_patch=/backup
file=backup-$(date +%Y%m%d).tar.gz
backupcwd=/root/backup
tar -cvf $backup_patch/$file $backupcwd
cd $backup_patch
sleep 1s
ftp -i -n <<!
open $host
user $username $passwd
put $file
bye
! |
|