ユーザ用ツール

サイト用ツール


temporary:asakusasatellite:backup
#!/bin/sh

#DB_NAME=$1
DB_NAME=asakusa_satellite_production

if [ -z $DB_NAME ]; then
  echo 'require database name'
  exit
fi

BACKUP_BASE_DIR=/var/backup
BACKUP_DIR=$BACKUP_BASE_DIR/$DB_NAME
DUMP_DIR=$BACKUP_DIR/dump
BACKUP_FILE=$BACKUP_DIR/${DB_NAME}_`date +"%Y%m%d-%H%M%S"`

# remove dump dir
rm -rf $DUMP_DIR

# dump db data
/usr/bin/mongodump -o $DUMP_DIR -d $DB_NAME

# remove old file
find $BACKUP_DIR -type f -mtime +30 | xargs rm -f

# compress
tar vczPf $BACKUP_FILE.tar.gz $DUMP_DIR
#tar cf - $DUMP_DIR | pbzip2 -f -p4 > $BACKUP_FILE.tar.bz2

## upload dir
cp -ir /var/AsakusaSatellite/public/upload $BACKUP_DIR/

tar vczPf $BACKUP_DIR/upload_`date +"%Y%m%d-%H%M%S"`.tar.gz $BACKUP_DIR/upload

# rsync
rsync -arv /var/backup/* /mnt/backup1/backup/
temporary/asakusasatellite/backup.txt · 最終更新: 2015/06/08 01:45 by clownclown

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki