From e6cad1d1326a6607e754b14b40e8180a056a7f28 Mon Sep 17 00:00:00 2001 From: FalkoInc <50336107+FalkoInc@users.noreply.github.com> Date: Thu, 13 Oct 2022 08:59:02 -0700 Subject: [PATCH 1/2] added backup system --- Dockerfile | 8 ++++++++ do-1st-backup.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 do-1st-backup.sh diff --git a/Dockerfile b/Dockerfile index 3b5cb5b..3e4c512 100644 --- a/Dockerfile +++ b/Dockerfile @@ -179,3 +179,11 @@ ADD ./etc/logrotate/rsyslog-rotate /usr/lib/rsyslog/rsyslog-rotate VOLUME ["/usr/local/ispconfig/"] CMD ["/bin/bash", "/start.sh"] + +RUN if [ -f "/var/backup/1st-backup-complete.log" ]; then \ + echo "1st Backup file exists. Nothing to do here" \ +else \ + echo "Waiting for 30 sec to ensure install is completed before doing the backup" \ + Sleep 30 \ + CMD ["/bin/bash", "/do-1st-backup.sh"] \ +fi \ No newline at end of file diff --git a/do-1st-backup.sh b/do-1st-backup.sh new file mode 100644 index 0000000..d2926ff --- /dev/null +++ b/do-1st-backup.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +output=/var/backup/1st-backup-complete.log + +#Sleep 30 +#echo "Waiting for 30 sec to ensure install is completed before doing the backup" + +if [ ! -f "$output" ] +then + cp -r --parents /var/lib/amavis/ /data_tmp/ + echo "/var/lib/amavis/ backed up 1st time" >> $output + cp -r --parents /etc/amavis/ /data_tmp/ + echo "/etc/amavis/ backed up 1st time" >> $output + cp -r --parents /etc/letsencrypt/ /data_tmp/ + echo "/etc/letsencrypt/ backed up 1st time" >> $output + cp -r --parents /etc/apache2/sites-available/ /data_tmp/ + echo "/etc/apache2/sites-available/ backed up 1st time" >> $output + cp -r --parents /etc/apache2/sites-enabled/ /data_tmp/ + echo "/etc/apache2/sites-enabled/ backed up 1st time" >> $output + cp -r --parents /usr/local/ispconfig/ /data_tmp/ + echo "/usr/local/ispconfig/ backed up 1st time" >> $output + cp -r --parents /etc/cron.d/ /data_tmp/ + echo "/etc/cron.d/ backed up 1st time" >> $output + cp -r --parents /etc/bind/ /data_tmp/ + echo "/etc/bind/ backed up 1st time" >> $output + cp -r --parents /var/vmail/ /data_tmp/ + echo "/var/vmail/ backed up 1st time" >> $output + cp -r --parents /var/www/ /data_tmp/ + echo "/var/www/ backed up 1st time" >> $output + dt=$(date '+%d/%m/%Y %H:%M:%S'); + echo "1st Backup Completed $dt" >> $output + echo "1st Backup Completed $dt" +else + echo "Backup log File found. No backup required, change to Persist Data" +fi \ No newline at end of file From 6583cb2d186898468a517bdafdb8b160c7de4607 Mon Sep 17 00:00:00 2001 From: FalkoInc <50336107+FalkoInc@users.noreply.github.com> Date: Sun, 16 Oct 2022 15:44:07 -0700 Subject: [PATCH 2/2] fixed some errors --- Dockerfile | 16 +++++++--------- do-1st-backup.sh | 6 ++++-- start.sh | 11 ++++++++++- 3 files changed, 21 insertions(+), 12 deletions(-) mode change 100644 => 100755 do-1st-backup.sh diff --git a/Dockerfile b/Dockerfile index 3e4c512..22ff68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -178,12 +178,10 @@ ADD ./etc/logrotate/rsyslog-rotate /usr/lib/rsyslog/rsyslog-rotate VOLUME ["/usr/local/ispconfig/"] -CMD ["/bin/bash", "/start.sh"] - -RUN if [ -f "/var/backup/1st-backup-complete.log" ]; then \ - echo "1st Backup file exists. Nothing to do here" \ -else \ - echo "Waiting for 30 sec to ensure install is completed before doing the backup" \ - Sleep 30 \ - CMD ["/bin/bash", "/do-1st-backup.sh"] \ -fi \ No newline at end of file +## Initial Backup +ADD ./do-1st-backup.sh /do-1st-backup.sh + +## FIX: mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109) +RUN echo "column-statistics=0" >> /etc/mysql/conf.d/mysqldump.cnf + +CMD ["/bin/bash", "/start.sh"] \ No newline at end of file diff --git a/do-1st-backup.sh b/do-1st-backup.sh old mode 100644 new mode 100755 index d2926ff..49027cf --- a/do-1st-backup.sh +++ b/do-1st-backup.sh @@ -2,11 +2,13 @@ output=/var/backup/1st-backup-complete.log -#Sleep 30 +#sleep 30 #echo "Waiting for 30 sec to ensure install is completed before doing the backup" if [ ! -f "$output" ] then + echo "Waiting for 30 sec to ensure install is completed before doing the backup" + sleep 30 cp -r --parents /var/lib/amavis/ /data_tmp/ echo "/var/lib/amavis/ backed up 1st time" >> $output cp -r --parents /etc/amavis/ /data_tmp/ @@ -29,7 +31,7 @@ then echo "/var/www/ backed up 1st time" >> $output dt=$(date '+%d/%m/%Y %H:%M:%S'); echo "1st Backup Completed $dt" >> $output - echo "1st Backup Completed $dt" + echo "1st Backup Completed $dt" else echo "Backup log File found. No backup required, change to Persist Data" fi \ No newline at end of file diff --git a/start.sh b/start.sh index b4f59f0..90eec63 100644 --- a/start.sh +++ b/start.sh @@ -10,6 +10,8 @@ cd /tmp/ispconfig3_install/install/ if [ -f /usr/local/ispconfig/interface/lib/config.inc.php ]; then + # Fixed: Table already exists + rm /tmp/ispconfig3_install/install/sql/incremental/upd_dev_collection.sql /wait-for-it.sh $isp_mysql_hostname:$isp_mysql_port -- php -q update.php --autoinstall=/tmp/ispconfig3_install/install/autoinstall.ini else /wait-for-it.sh $isp_mysql_hostname:$isp_mysql_port -- php -q install.php --autoinstall=/tmp/ispconfig3_install/install/autoinstall.ini @@ -79,4 +81,11 @@ chown root:bind /etc/bind/rndc.key # fix index permission error chown courier: /etc/courier/shared/index -/usr/bin/supervisord -c /etc/supervisor/supervisord.conf +if [ -f "/var/backup/1st-backup-complete.log" ]; +then + echo "1st Backup file exists. Nothing to do here" +else + /do-1st-backup.sh & +fi + +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf \ No newline at end of file