Thursday, April 26, 2012

BASH and PHP problem solving

I had a problem where I was trying to get a BASH script to run a backup extension on a Joomla site the other day. It was hosted on a shared server on HostGator with my only access being cpanel. For some reason my cron job wasn't firing when I thought it should. It would only work when I scheduled a recurring job every few minutes. I had to look up the PHP code but I wrote something like <?PHP echo date(r); ?> into a time.php file and uploaded it, then navigating to that location with my browser gave me the local time on the server. The server's time was 1 hour in the past which is why my cron jobs set to specific time weren't firing. I set my job to an hour in the past, and it worked that time and since.

The backup extension is Akeeba Backup. One of the features in it is a frontend triggered backup. You can set up a secret word, so just not anyone can trigger it and use something like wget to make it run. There is an integrated backup if you want to pay money for the Pro version. This way you can do scheduled backups with the free version. It's also relatively easy in BASH to delete older files. I haven't had to do anything fancy like keep certain day backups, or only keep x number of backups no matter when they were made.

No comments:

Post a Comment