Avoid multiple local database backups
This commit is contained in:
parent
ab03b8e159
commit
92edc9d62d
|
@ -44,6 +44,7 @@ function backup_database_local {
|
||||||
database_name=$1
|
database_name=$1
|
||||||
|
|
||||||
backup_databases_script=/usr/bin/backupdatabases
|
backup_databases_script=/usr/bin/backupdatabases
|
||||||
|
if ! grep -q "# Backup the ${database_name} database" $backup_databases_script; then
|
||||||
echo '' >> $backup_databases_script
|
echo '' >> $backup_databases_script
|
||||||
echo "# Backup the ${database_name} database" >> $backup_databases_script
|
echo "# Backup the ${database_name} database" >> $backup_databases_script
|
||||||
echo "TEMPFILE=/root/${database_name}.sql" >> $backup_databases_script
|
echo "TEMPFILE=/root/${database_name}.sql" >> $backup_databases_script
|
||||||
|
@ -70,29 +71,33 @@ function backup_database_local {
|
||||||
echo ' # Make the backup readable only by root' >> $backup_databases_script
|
echo ' # Make the backup readable only by root' >> $backup_databases_script
|
||||||
echo ' chmod 600 $DAILYFILE' >> $backup_databases_script
|
echo ' chmod 600 $DAILYFILE' >> $backup_databases_script
|
||||||
echo 'fi' >> $backup_databases_script
|
echo 'fi' >> $backup_databases_script
|
||||||
|
echo "# End of ${database_name} database backup" >> $backup_databases_script
|
||||||
|
fi
|
||||||
|
|
||||||
weekly_backup_script=/etc/cron.weekly/backupdatabasesweekly
|
weekly_backup_script=/etc/cron.weekly/backupdatabasesweekly
|
||||||
if ! grep -q "${database_name}" ${weekly_backup_script}; then
|
if ! grep -q "Backup ${database_name}" ${weekly_backup_script}; then
|
||||||
echo '' >> ${weekly_backup_script}
|
echo '' >> ${weekly_backup_script}
|
||||||
echo "# ${database_name}" >> ${weekly_backup_script}
|
echo "# Backup ${database_name}" >> ${weekly_backup_script}
|
||||||
echo "if [ -f /var/backups/${database_name}_weekly.sql ]; then" >> ${weekly_backup_script}
|
echo "if [ -f /var/backups/${database_name}_weekly.sql ]; then" >> ${weekly_backup_script}
|
||||||
echo " cp -f /var/backups/${database_name}_weekly.sql /var/backups/${database_name}_2weekly.sql" >> ${weekly_backup_script}
|
echo " cp -f /var/backups/${database_name}_weekly.sql /var/backups/${database_name}_2weekly.sql" >> ${weekly_backup_script}
|
||||||
echo 'fi' >> ${weekly_backup_script}
|
echo 'fi' >> ${weekly_backup_script}
|
||||||
echo "if [ -f /var/backups/${database_name}_daily.sql ]; then" >> ${weekly_backup_script}
|
echo "if [ -f /var/backups/${database_name}_daily.sql ]; then" >> ${weekly_backup_script}
|
||||||
echo " cp -f /var/backups/${database_name}_daily.sql /var/backups/${database_name}_weekly.sql" >> ${weekly_backup_script}
|
echo " cp -f /var/backups/${database_name}_daily.sql /var/backups/${database_name}_weekly.sql" >> ${weekly_backup_script}
|
||||||
echo 'fi' >> ${weekly_backup_script}
|
echo 'fi' >> ${weekly_backup_script}
|
||||||
|
echo "# End of backup for ${database_name}" >> ${weekly_backup_script}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
monthly_backup_script=/etc/cron.monthly/backupdatabasesmonthly
|
monthly_backup_script=/etc/cron.monthly/backupdatabasesmonthly
|
||||||
if ! grep -q "${database_name}" ${monthly_backup_script}; then
|
if ! grep -q "Backup ${database_name}" ${monthly_backup_script}; then
|
||||||
echo '' >> ${monthly_backup_script}
|
echo '' >> ${monthly_backup_script}
|
||||||
echo "# ${database_name}" >> ${monthly_backup_script}
|
echo "# Backup ${database_name}" >> ${monthly_backup_script}
|
||||||
echo "if [ -f /var/backups/${database_name}_monthly.sql ]; then" >> ${monthly_backup_script}
|
echo "if [ -f /var/backups/${database_name}_monthly.sql ]; then" >> ${monthly_backup_script}
|
||||||
echo " cp -f /var/backups/${database_name}_monthly.sql /var/backups/${database_name}_2monthly.sql" >> ${monthly_backup_script}
|
echo " cp -f /var/backups/${database_name}_monthly.sql /var/backups/${database_name}_2monthly.sql" >> ${monthly_backup_script}
|
||||||
echo 'fi' >> ${monthly_backup_script}
|
echo 'fi' >> ${monthly_backup_script}
|
||||||
echo "if [ -f /var/backups/${database_name}_weekly.sql ]; then" >> ${monthly_backup_script}
|
echo "if [ -f /var/backups/${database_name}_weekly.sql ]; then" >> ${monthly_backup_script}
|
||||||
echo " cp -f /var/backups/${database_name}_weekly.sql /var/backups/${database_name}_monthly.sql" >> ${monthly_backup_script}
|
echo " cp -f /var/backups/${database_name}_weekly.sql /var/backups/${database_name}_monthly.sql" >> ${monthly_backup_script}
|
||||||
echo 'fi' >> ${monthly_backup_script}
|
echo 'fi' >> ${monthly_backup_script}
|
||||||
|
echo "# End of backup for ${database_name}" >> ${monthly_backup_script}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! grep -q "${database_name}" /etc/cron.hourly/repair; then
|
if ! grep -q "${database_name}" /etc/cron.hourly/repair; then
|
||||||
|
|
Loading…
Reference in New Issue