web-dev-qa-db-ja.com

RackspaceCloudでのAutoMySQLBackupの使用

Rackspace CloudはFTPアクセスのみを許可しているため、AutoMySQLBackupの使用が少し難しくなり、少なくともDBダンプを作成している間、バックアップログにエラーが記録されます。

###### WARNING ######
Errors reported during AutoMySQLBackup execution.. Backup failed
Error log below..
.../backups/automysqlbackup: line 1791: /usr/bin/find: Permission denied
.../backups/automysqlbackup: line 1855: /usr/bin/find: Permission denied
.../backups/automysqlbackup: line 803: /usr/bin/find: Permission denied
.../backups/automysqlbackup: line 1972: /usr/bin/du: Permission denied

ファイルが作成されているので、findコマンドの失敗は、実際にローテーションして古いバックアップを削除することに関係していると思いますか?

803行目:

find "${CONFIG_backup_dir}/${subfolder}${subsubfolder}" -mtime 
+"${rotation}" -type f -exec rm {} \;

代替案のアイデアはありますか?

1
xref

前述のように elsewhere 、RackspaceCloudはfindコマンドへのアクセスを許可していません。おそらく、ある種のセキュリティ上の懸念がありますか?いずれにせよ、私は、findコマンドなしで毎日/毎週/毎月のバックアップをバージョン管理する他の誰かのbashスクリプトに基づいて構築することになりました。

#!/bin/bash
####################################
#
# Purpose:  Create daily, weekly and monthly rotating backups
#           (Originally for WordPress web content and MySQL DB
#           on Rackspace Cloud Sites)
#
#####################################

##### SETTINGS #####
BACKUP_NAME="SOMEWEBSITE Web & DB Backup"                               # What is the name of this backup?
BACKUP_SITEROOT=""                                                      # Root directory of website
BACKUP_TARGET=$BACKUP_SITEROOT"/backups"                                # Where to store the backups
BACKUP_FILES=$BACKUP_SITEROOT"/web/content"                             # What directories to backup

# Database info
DB_USER=""
DB_PASS=""
DB_Host=""
DB_NAME=""

# How many weekly backups and monthly backups to save
WEEKS_TO_SAVE=4     # default: 4
MONTHS_TO_SAVE=6    # default: 6

# Which day of the week and month to version backups on
BACKUP_DAYOFWEEK="Saturday"  # default: "Saturday"
BACKUP_DAYOFMONTH=1          # default: 1

# Archive file names
ARCHIVE_DB="db_backup_"`date +%Y-%m-%d`
ARCHIVE_WEB="web_backup_"`date +%Y-%m-%d`.tar.bz2

/bin/echo "======================================================================"
/bin/echo "Starting Backup Task:" $BACKUP_NAME
/bin/echo "======================================================================"

# CREATE DAILY BACKUP
/bin/echo "Creating daily backup archives..."

# Check to make sure the folders exist, if not create them.
/bin/mkdir -p $BACKUP_TARGET/daily.{0..6}

# Delete the oldest backup folder.
/bin/rm -rf $BACKUP_TARGET/daily.7

# Shift all the backup folders up a day.
for i in $(eval echo {7..1})
 do
    /bin/mv $BACKUP_TARGET/daily.$[${i}-1] $BACKUP_TARGET/daily.${i}
 done

# Create tar'ed and bzip2 archive of web content
tar cfj $BACKUP_TARGET/daily.1/$ARCHIVE_WEB $BACKUP_FILES

# Dump MySQL DB and create bzip2 archive
mysqldump --opt -h $DB_Host -u $DB_USER -p$DB_PASS $DB_NAME > $BACKUP_TARGET/daily.1/$ARCHIVE_DB.sql
bzip2 $BACKUP_TARGET/daily.1/$ARCHIVE_DB.sql

# CREATE WEEKLY BACKUP
DAYOFWEEK=$(date +%A)
if [ $DAYOFWEEK == $BACKUP_DAYOFWEEK ]
then
    /bin/echo "It's" $DAYOFWEEK"! Copying latest Daily backups to Weekly..."

    # Check to make sure the folders exist, if not create them.
    eval "/bin/mkdir -p $BACKUP_TARGET/weekly.{0..$WEEKS_TO_SAVE}"

    # Delete the oldest backup folder.
    /bin/rm -rf $BACKUP_TARGET/weekly.$WEEKS_TO_SAVE

    # Shift all the backup folders up a day.
    for i in $(eval echo {$WEEKS_TO_SAVE..1})
     do
        /bin/mv $BACKUP_TARGET/weekly.$[${i}-1] $BACKUP_TARGET/weekly.${i}
     done

    # Copy archives to weekly
    /bin/cp $BACKUP_TARGET/daily.1/* $BACKUP_TARGET/weekly.1/
else
    /bin/echo "Skipping Weekly archive creation until" $BACKUP_DAYOFWEEK
fi

# CREATE MONTHLY BACKUP 
DAYOFMONTH=$(date +%d)
if [ $DAYOFMONTH -eq $BACKUP_DAYOFMONTH ]
then
    /bin/echo "It's the" $DAYOFMONTH"st! Copying latest Daily backups to Monthly..."

    eval "/bin/mkdir -p $BACKUP_TARGET/monthly.{0..$MONTHS_TO_SAVE}"

    # Delete the oldest backup folder.
    /bin/rm -rf $BACKUP_TARGET/monthly.$MONTHS_TO_SAVE

    # Shift all the backup folders up a day.
    for i in $(eval echo {$MONTHS_TO_SAVE..1})
     do
        /bin/mv $BACKUP_TARGET/monthly.$[${i}-1] $BACKUP_TARGET/monthly.${i}
     done

    # Copy archives to monthly
    /bin/cp $BACKUP_TARGET/daily.1/* $BACKUP_TARGET/monthly.1/
else
    /bin/echo "Skipping Monthly archive creation until the" $BACKUP_DAYOFMONTH"st"
fi

/bin/echo "======================================================================"
/bin/echo "Completed Backup Task:" $BACKUP_NAME
/bin/echo "======================================================================"
1
xref