diff --git a/Dockerfile b/Dockerfile index 3b5cb5b..22ff68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -178,4 +178,10 @@ ADD ./etc/logrotate/rsyslog-rotate /usr/lib/rsyslog/rsyslog-rotate VOLUME ["/usr/local/ispconfig/"] -CMD ["/bin/bash", "/start.sh"] +## 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 new file mode 100755 index 0000000..49027cf --- /dev/null +++ b/do-1st-backup.sh @@ -0,0 +1,37 @@ +#!/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 + 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/ + 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 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