Created
August 18, 2014 11:38
-
-
Save cmpscabral/38ca569145e12b971fca to your computer and use it in GitHub Desktop.
backup script example
This file contains hidden or 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/sh | |
renice 19 -p $$ | |
ionice -c 3 -p $$ | |
# change to script folder | |
cd ${0%/*} | |
TODAY=`date --rfc-3339=ns` | |
SOURCE="www" | |
TARGET="/home/www_dumps" | |
MYSQL="/home/mysql_dumps" | |
mkdir -p "$TARGET" | |
echo "=================================" | |
echo "starting backup for $TODAY..." | |
echo "=================================" | |
find "$MYSQL"/* -maxdepth 0 -type d | while read DIRNAME1 | |
do ARCHNAME1=$(basename "$DIRNAME1") | |
echo sending "$ARCHNAME1" to s3... | |
s3cmd put "$MYSQL/$ARCHNAME1"/latest.zip s3://[mybucket]/mysql/"$ARCHNAME1".zip | |
echo sending "$ARCHNAME1" OK | |
echo | |
done | |
find "$SOURCE"/* -maxdepth 0 -type d | while read DIRNAME | |
do ARCHNAME=$(basename "$DIRNAME") | |
echo zipping "$TARGET/$ARCHNAME".tar.gz "$DIRNAME"... | |
tar czf "$TARGET/$ARCHNAME".tar.gz "$DIRNAME" | |
echo zipping "$TARGET/$ARCHNAME".tar.gz "$DIRNAME" OK | |
echo sending "$TARGET/$ARCHNAME".tar.gz to s3... | |
s3cmd put "$TARGET/$ARCHNAME".tar.gz s3://[mybucket]/www/"$ARCHNAME".tar.gz | |
echo sending "$TARGET/$ARCHNAME".tar.gz to s3 OK | |
echo | |
done | |
echo "=================================" | |
echo | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment