Google Driveに諸々バックアップするんやで

#!/bin/bash

BASEDIR=/root/backup

function execmd () {
    echo "$ $1" >> $BASEDIR/backup.log
    $1 >> $BASEDIR/backup.log
    echo >> $BASEDIR/backup.log
}

echo "[Backup log]" >> $BASEDIR/backup.log
echo >> $BASEDIR/backup.log

execmd "mkdir -p $BASEDIR/backup"
execmd "sh $BASEDIR/backup_mysql.sh"
execmd "tar -zcvf $BASEDIR/backup/home.tar.gz -C / home"
execmd "tar -zcvf $BASEDIR/backup/var_www_git.tar.gz -C / var/www/git"
execmd "tar -zcvf $BASEDIR/backup/var_www_html.tar.gz -C / var/www/html"
execmd "tar -zcvf $BASEDIR/backup/etc_httpd.tar.gz -C / etc/httpd"
execmd "tar -zcvf $BASEDIR/backup/usr_share_phpMyAdmin.tar.gz -C / usr/share/phpMyAdmin"
execmd "cp -p /etc/bashrc $BASEDIR/backup/etc_bashrc"
execmd "cp -p /etc/vimrc $BASEDIR/backup/etc_vimrc"
execmd "cp -p  $BASEDIR/backup.sh $BASEDIR/backup/root_backup_backup_backup.sh"
execmd "cp -p  $BASEDIR/backup_mysql.sh $BASEDIR/backup/root_backup_backup_backup_mysql.sh"

execmd "tar -zcvf $BASEDIR/backup.tar.gz -C / root/backup/backup"
execmd "rm -rv --interactive=never $BASEDIR/backup"
execmd "mv $BASEDIR/backup.tar.gz $BASEDIR/backup-`date '+%Y%m%d'`.tar.gz"
/usr/local/bin/gdrive upload -p [Dir ID] $BASEDIR/backup-*.tar.gz
execmd "rm -rv --interactive=never $BASEDIR/backup-*.tar.gz"

# log
cat $BASEDIR/backup.log | mail -s "Backup of www.test.com" hoge@gmail.com
mv $BASEDIR/backup.log $BASEDIR/backup-`date '+%Y%m%d'`.log
/usr/local/bin/gdrive upload -p 1lXDeJIxxiz8F7QQGF-quF07h3CKbKpXW $BASEDIR/backup-*.log
rm --interactive=never $BASEDIR/backup-*.log

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA