Cron jobs


#1

Hello. Can someone help me out with this cron job? Basically, i want “www.example.com/cheese” to be backed up every day at 3AM. I want 3 copies to be kept before overwriting of the oldest copy begins on the fourth day. I know where to do this in the DH panel. I just dont know how to structure the actual command itself. Thanks.


#2

DreamHost does create backups of all your files in the hidden “.snaphot” directory. There are 2 hourly snapshots, 2 daily snapshots and 2 weekly snapshots. Possibly these backups would be sufficient? Details at:

http://wiki.dreamhost.com/Automated_domain_snapshots


#3

Did not even know they did that. Thanks! However, for future, i would still like to know what the appropriate command looks like.


#4

I think Scott provided a reply recently on how to go about backing up a file/folder/domain on a rotating basis. You could try doing a Search and make sure to set the date thingamajig to 6 months rather than the default setting.

Failing that, I’m sure he’ll be in today to set you straight.

Maximum Cash Discount on any plan with MAXCASH


#5

That doesn’t sound familiar, but a shell script would be something like:

rotate.sh

#!/bin/bash
cd ~ # go to home directory
/bin/mv -f backup1.tar backup2.tar #rename old backup to oldest backup
/bin/mv -f backup0.tar backup1.tar #rename new backup to old backup
/bin/tar -cf example.com backup0.tar #create new backup of example.com folder

The cronjob would be:
0 3 * * * ~/rotate.sh #runs rotate script at 0 minutes after 3am every day, every month, every day of week

Personally, I rsync my entire directory from home periodically with the following script:
#!/bin/bash
/usr/bin/ssh me@mydomain.com ‘/usr/bin/mysqldump --all-databases -hdb.mydomain.com -uUSER1 -pPASS1 > db1.sql’ # first database
/usr/bin/ssh me@mydomain.com ‘/usr/bin/mysqldump --all-databases -hdb.mydomain.com -uUSER2 -pPASS2 > db2.sql’ # second database
rsync -avze ssh --delete ‘me@mydomain.com:.’ ‘/home/me/backups/mydomain’ # create a local mirror of my home directory w/databases
/usr/bin/ssh me@mydomain.com /bin/rm *.sql # delete database backup dump files on server

-Scott