Web Hosting Talk







View Full Version : cron jobs


-Edward-
11-01-2002, 04:47 PM
Hi,

I want to set it up so that my community website backs it's self up to a certain directory. How would i set it up so that it will tar mysite up and send it to a directory not accesable on the web?

BruceT
12-05-2002, 12:20 AM
1. Log in as root
2. mkdir -p /home/backups
3. crontab -e
4. 55 0 * * * tar czvf /home/backups/backup.tgz /home/sites/siteX/web/*

(where siteX is the site number of your domain)

This will run at 00:55 every night and put a compressed tarball of the web dir for siteX in /home/backups

-Edward-
12-05-2002, 08:14 AM
Thanks thats very helpful!

Could you help with a few other options:

How could i do this but send it too another server?

How can i perform the samething with the websites mysql database?

BruceT
12-07-2002, 05:54 AM
To send to a different server, you'd need to use rsync, scp, etc.

If you have SSH installed, you have scp (secure copy). You can do 'man scp' for all the options which are available (they're pretty involved so i don't want to try and list them all out here).

For MySQL, do a schema dump first (MySQL site has documentation), then tar up the schema file, and either keep it local, or use scp, etc, to copy to another server.

I'll be gone all weekend, but if you still want more specifics, please PM me and I'll try to do up some specific instructions on Monday for you.

Bob_Isaac
01-05-2003, 02:05 PM
Bruce

I tried what you said about setting up this cron job, but when I typed crontab -e I got a page full of ~ down the left and at the bottom was "/tmp/crontab.3770" OL. OC. I could not use and keys to move the cursor or type anything in.

Bob

BruceT
01-06-2003, 04:04 PM
Yeah, you're in 'vi' when you edit the crontab file. 'man vi' for more info, but here's some quick info:

press 'i' to go into insert mode (then it works like any regular screen editor - just start typing. use arrows, delete, etc)

press 'esc' to go to command mode. common commands are:

:wq 'write changes and exit'

:q! 'quit, don't save changes'

dd 'delete the entire line my cursor is on'

x 'delete the character under my cursor'

A 'go to the end of the line, and go into insert mode'

That should get you started... with vi, when in doubt, hit escape a couple of times, and do :q! to exit without saving any changes