Ubuntu Backups

Hi i tried opening this link http://www.bradymd.com/appliance/manual9/#__RefHeading__5628_695817034
to get more info on the Ubuntu backup script. I am looking for a script or tool that can do backups of OpenEMR + mysql backups on a weekly basis. Or is there a modified version of the backup.php script that can run on cron?

Thank you!

try this @Daniel1, https://www.open-emr.org/wiki/index.php/Automated_Backups_to_an_Alternate_Server

1 Like

Thank you, this is what I was looking for!

I used the script provided, it seems to be working, but for some reason the following code is throwing me a syntax error: bad loop for variable:

Delete the oldest allowed historical backup and rename the others to make room for a new one.

rm -f $SHORT.$NUMBACKUPS.tar.gz
for ((I=NUMBACKUPS; I > 1; I=I-1)); do( syntax error from this line)
J=$((I-1))
if [ -e “$SHORT.$J.tar.gz” ]; then
mv $SHORT.$J.tar.gz $SHORT.$I.tar.gz
fi
done

I commented it out and the backup is successful without it, but I would like to be able rename the older backups.
I will try to continue to debug, but if anyone has run into this and has the solution, it would be greatly appreciated. Thanks!

maybe your version of bash, https://stackoverflow.com/questions/30358065/syntax-error-bad-for-loop-variable

Thanks! turned out it was because I had copied over the script from a Windows PC to the Ubuntu instead of creating it from Linux. https://unix.stackexchange.com/questions/144718/sudo-unable-to-execute-script-sh-no-such-file-or-directory#144719
Once I re-wrote it using nano it was fine.
The only other issue I am having is once I restore the www file to the production server using the instructions found here: https://www.open-emr.org/wiki/index.php/Automated_Backups_to_an_Alternate_Server ,
All the permissions are reset to root only and I cannot access files such as /www/openemr/sites/default/documents
from www-data.

Oh nice, sudo chown -R www-data: /www/openemr/sites/default should work

1 Like

Thanks @stephenwaite ! is /Sites/default the only folder I need to give chown -R to www-data? Thanks again for your help!

1 Like

good question,

https://www.open-emr.org/wiki/index.php/OpenEMR_5.0.0_Linux_Installation#Post-install_FileSystem_Permission_Cleanups

https://www.open-emr.org/wiki/index.php/Securing_OpenEMR

kind of makes you want to run OpenEMR Cloud? :wink:

FYI @stephenwaite @brady.miller , I like renaming previous backups to include the date it was backed up. If anyone wants to use this python script to rename to include date, I posted it on Github. I set the backup script to run nightly using Crontab and included a python command to execute the python script after the backup completes.

3 Likes