cr0n_dist0rti0n
Cadet
- Joined
- Nov 21, 2016
- Messages
- 4
I am backing up our Moodle website which is setup within a Jail. I have been running the backup script in the jail's crontab because putting the site into maintenance mode requires that it be run within the jail. The script runs fine when I run it myself from the console. Interestingly enough, the script also seems to run fine when I do a test run through the crontab by setting it say a couple minutes ahead of the current clock. However, when I set the crontab to run at 5am everyday it apparently take 12 hours to transfer 8.3 gigs @ 100Mbps. Obviously this should not take 12 hours. More like 12 minutes. I have used both SCP and RSYNC but they both do the same thing. Clearly there is something that I'm missing here but I just don't see it. Below is a copy of my script and crontab. The current script is using RSYNC but my previous one SCPd all the files individually.
Crontab:
Script:
I have thought about just running the transfer from outside the jail in the regular GUI crontab but it would be nice to not split up the process and it seems silly that I should. Any ideas on how to problem solve this?
Crontab:
Code:
SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin # Order of crontab fields # minute hour mday month wday command */15 * * * * /usr/local/bin/php /usr/local/www/apache24/data/moodle/admin/cli/cron.php >/dev/null * 5 * * * /root/moodle_backup.sh > /root/moodle_backup.log
Script:
Code:
#!/bin/sh #Set variable to date now=$(date -v-1d +"%Y-%m-%d") #Maintenance Mode Enabled /usr/local/bin/php /usr/local/www/apache24/data/admin/cli/maintenance.php --enable #MySQL Dump /usr/local/bin/mysqldump -u root --password=******** -C -Q -e --create-options moodle > /root/moodle_backup/moodle-database_$now.sql #Compress Moodle /usr/bin/tar --exclude='./wordpress' -zcvf /root/moodle_backup/moodle_$now.tar.gz /usr/local/www/apache24/data/ #Compress Moodle Data /usr/bin/tar -zcvf /root/moodle_backup/moodledata_$now.tar.gz /usr/local/www/apache24/moodledata #Maintenance Mode Disabled /usr/local/bin/php /usr/local/www/apache24/data/admin/cli/maintenance.php --disable #Rsync Transfer Files /usr/local/bin/rsync -av /root/moodle_backup/ moodlebak@10.12.50.10:~/moodle_backup/ #Delete Local Backups /bin/rm -fr /root/moodle_backup/moodle-database_$now.sql /bin/rm -fr /root/moodle_backup/moodledata_$now.tar.gz /bin/rm -fr /root/moodle_backup/moodle_$now.tar.gz
I have thought about just running the transfer from outside the jail in the regular GUI crontab but it would be nice to not split up the process and it seems silly that I should. Any ideas on how to problem solve this?
Last edited: