0

I need to change the following cron so that it only tars images with a pattern of: l_*.jpg What modifications does my current cron require?

0 4 * * 1 tar vcf /home/XXXXXX/public_html/backups/monday_backup.tar /home/XXXXXX/public_html/images/products 
bikey77
  • 6,384
  • 20
  • 60
  • 86

1 Answers1

0

Try something like this:

0 4 * * 1   find /home/XXXXXX/public_html/images/products -iname "l_*.jpg" | tar vcf /home/XXXXXX/public_html/backups/monday_backup.tar --files-from=-

It's really simple to create a script-file. Just make a text file with content.

#!/bin/bash
date
echo It is a blue day

Place that file into private folder (folder not accessable by browser) on the host. Using cpanel set executable permissions on it.

Try to run it from cron:

*/2 * * * *   /home/XXXXXX/private_scripts/backup-script 2>&1 >> /home/XXXXXX/private_scripts/backup-log

Check content of /home/XXXXXX/private_scripts/backup-log. If you see messages 'It is a blue day', than cron setup and script are ok.

If you don't see anything, then try to replace '#!/bin/bash' with '#!/bin/sh'. Double check paths.

If you setup script successesfully, then add to the end of script the line:

find /home/XXXXXX/public_html/images/products -iname "l_*.jpg" | tar vcf /home/XXXXXX/public_html/backups/monday_backup.tar --files-from=- 
alexander
  • 2,703
  • 18
  • 16
  • Didnt work but I'm afraid I dont have enough experience to find the reason. – bikey77 Feb 15 '12 at 07:54
  • Do you know how to create a simple shell script file and run it on the host? – alexander Feb 15 '12 at 08:40
  • BTW, most hosting providers do daily backups of site which can be accessed using site control panel. So may be it is easier for you to use standard solution. – alexander Feb 15 '12 at 08:56
  • I know that, I need to perform additional backups though. @alexander: I know how to set a cron in CPanel but not on a console. – bikey77 Feb 16 '12 at 07:39