Created
October 31, 2015 09:54
-
-
Save laoshuterry/30f1724aa87d8b7b7299 to your computer and use it in GitHub Desktop.
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 | |
#备份数据库 | |
datetime=$(date +%y%m%d) | |
size=$(du -sh /home/fatmouse/sh) | |
if [ -d /home/fatmouse/backup ];then | |
echo "Date: $datetime">/home/fatmouse/sh/info.txt | |
echo "Size: $size" >>/home/fatmouse/sh/info.txt | |
cd /home/fatmouse/backup | |
tar -zcf Backup_$datetime.tar.gz /home/fatmouse/sh /home/fatmouse/info.txt &> /dev/null | |
rm -rf /home/fatmouse/sh/info.txt | |
else | |
mkdir /home/fatmouse/backup | |
echo "Date: $datetime">/home/fatmouse/sh/info.txt | |
echo "Size: $size" >>/home/fatmouse/sh/info.txt | |
cd /home/fatmouse/backup | |
tar -zcf Backup_$datetime.tar.gz /home/fatmouse/sh /home/fatmouse/info.txt &> /dev/null | |
rm -rf /home/fatmouse/sh/info.txt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment