Shell Script in Jail: TAR doesn't quit

Status
Not open for further replies.
Joined
Nov 21, 2016
Messages
4
I am having an issue backing up our moodle server. This is with FreeNAS11. For some reason it seems like the TAR never stops despite it finishing and creating an actual file. Or, for whatever reason, the Hard Drive is continually accessed at a rate of 20 to 30 MBs until I reset the jail with:

Code:
sudo service jail onerestart moodle


When I look at the PIDs there are a bunch of TAR processes. Additionally, through the FreeNAS GUI I can see that the HDDs (mirror raid) are being utilized at a 20 to 30 MBs rate for hours with an initial rate of 40-60MBs. When I have attempted to do run the script outside my Crontab, but still in the jail, the whole script takes about 25 minutes and runs fine. The interesting bit is it creates the backups fine and transfers the site to the live backup but there still is continual access by TAR and HDDs usage. Here is my shell script:

Code:
#!/bin/sh

#Set variable to date
now=$(date -v-1d +"%Y-%m-%d")

#Maintenance Mode Enabled
echo "$(date +%Y-%m-%d/%H:%M:%S) START: Maintenance Mode Enabled"
/usr/local/bin/php /usr/local/www/apache24/data/admin/cli/maintenance.php --enable
echo "$(date +%Y-%m-%d/%H:%M:%S) END: Maintenance Mode Enabled"

#MySQL Dump
echo "$(date +%Y-%m-%d/%H:%M:%S) START: MySQL Dump"
/usr/local/bin/mysqldump -u **** --password=**** -C -Q -e --set-gtid-purged=off --create-options moodle > /root/moodle_backup/moodle-database_$now.sql
echo "$(date +%Y-%m-%d/%H:%M:%S) END: MySQL Dump"

#Compress Moodle
echo "$(date +%Y-%m-%d/%H:%M:%S) START: Moodle Site TAR"
/usr/bin/tar -cf /root/moodle_backup/moodle_$now.tar /usr/local/www/apache24/data/
echo "$(date +%Y-%m-%d/%H:%M:%S) END: Moodle Site TAR"

#Compress Moodle Data
echo "$(date +%Y-%m-%d/%H:%M:%S) START: Moodle Data TAR"
/usr/bin/tar -cf /root/moodle_backup/moodledata_$now.tar /usr/local/www/apache24/moodledata
echo "$(date +%Y-%m-%d/%H:%M:%S) END: Moodle Data TAR"

#moodlepcs to Ubuntu-MT (live backup)
echo "$(date +%Y-%m-%d/%H:%M:%S) START: Ubuntu MT"
/usr/bin/ssh [usr]@[IP] "php /usr/local/www/apache24/data/admin/cli/maintenance.php --enable"
/usr/local/bin/rsync -rltPz --exclude 'config.php' /usr/local/www/apache24/data/ [usr]@[IP]:/usr/local/www/apache24/data
/usr/local/bin/rsync -rltPz /usr/local/www/apache24/moodledata/ [usr]@[IP]:/usr/local/www/apache24/moodledata
/usr/bin/sed -e 's/[Old HTTP]/[New HTTP]/g' /root/moodle_backup/moodle-database_$now.sql > /root/moodle_backup/moodle-database_MT.sql
/usr/bin/scp /root/moodle_backup/moodle-database_MT.sql [usr]@[IP]:~/moodlepcs_transfer/
/usr/bin/ssh [usr]@[IP] "mysql -u**** -p**** moodle < ~/moodlepcs_transfer/moodle-database_MT.sql"
/usr/bin/ssh [usr]@[IP] "php /usr/local/www/apache24/data/admin/cli/maintenance.php --disable"
echo "$(date +%Y-%m-%d/%H:%M:%S) END: Ubuntu MT"

#Maintenance Mode Disabled
echo "$(date +%Y-%m-%d/%H:%M:%S) START: Maintenance Mode Disabled"
/usr/local/bin/php /usr/local/www/apache24/data/admin/cli/maintenance.php --disable
echo "$(date +%Y-%m-%d/%H:%M:%S) END: Maintenance Mode Disabled"


My crontab is as follows:
Code:
* 1 * * * /root/moodle_backup.sh > /root/moodle_backup.log


Why does this not run properly under Crontab or just continually runs without stopping? Is there something wrong with my code? Anyone have any ideas
 
Joined
Nov 21, 2016
Messages
4
Realized my crontab was wrong. Dumb oversight on my part. Should have been 0 1 * * *. I distorted my own cron. WTF?
 
Status
Not open for further replies.
Top