Cron command to backup a website

Apache, Fedora core 2. In plesk the automated backup command doesnt work, so is there a cron command I can use to backup the database and files daily?

LVL 12
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for the database you need to use the tools provided by the database, otherwise the backed up files may be inconsistent
In most ceses you have to shutdown the database, perform the back up, then restart the database.
I'd write a script for that which also create a targall or rsyncs your other files, then simply call this script from cron.
Sam PanwarSr. Server AdministratorCommented:

Its pretty easy to write a script with PHP that will run the mysql dump command, and transfer the sql file produced to another server through FTP. You can set this up as a cron job to run daily, to copy the data to another server through FTP, or just produce the sql file and you can download it manually through FTP. You could also use PHP to automate the process of
using gzip to zip up the site files, and sending it to another server through FTP.

Scheduling With the at Command

You can use the at command to schedule a command or script to run a single time. The command includes several utilities.

If you want to schedule a command more than once, look into the crontab command.

By default, only the root user can use the at command. However, the root user can use two files to allow regular users the command:

/etc/at.allow: If this file exists, only users listed in it can use the command.

/etc/at.deny: If this file exists, users listed in it cannot use the command.

The at command depends on a plain text file. This file lists commands or scripts, one per line. The end of the file must be marked by <EOT> on a line by itself.

The time for a task can be set using several formats. The simplest is a 24 hour clock in the hh:mm format, followed by the date in the mm: dd:yyyy format.

You can enter commands by entering the name of a plain text file in which commands or scripts are listed, one per line. Type: at -f file command time date .


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Scheduling With the crontab Command

You can use the crontab command to run commands at regular times. For example, you could schedule a backup of your files every Friday. Commands can be scheduled to the minute.

If you want to schedule a command to run only once, look into the at command.

The crontab command works by reading a crontab file. A crontab file is a plain text file that lists all the jobs you have scheduled.

Each line of the crontab file consists of the command with all its options and arguments, and the date and time to run it.

By default, all users can set up their own crontab files. However, the root user can use two files to control access:

/etc/cron.allow: If this file exists, only users listed in it can use crontab.

/etc/cron.deny: If this file exists, users listed in it cannot use crontab.

All crontab files are stored in the /var/spool/cron/crontabs/ directory. However, since regular users do not have read or write permission to this directory, they must use the crontab command to schedule jobs.

Cron, as supplied in Debian, has two purposes:

To run system jobs on a daily/weekly/monthly basis

To allow users to setup their own schedules

The system schedules are setup when the package is installed, via the creation of some special directories:


Except for hte first one which is special, these directories allow scheduling of system-wide jobs in a coarse manner. Any script which is executable and placed inside them will run at the frequency which its name suggests.

For example if you place a script inside /etc/cron.daily it will be executed once per day, every day.

The time that the scripts run in those system-wide directories is not something that an administration typically changes, but the times can be adjusted by editing the file /etc/crontab. The format of this file will be explained shortly.

The normal manner which people use cron is via the crontab command. This allows you to view or edit your crontab file, which is a per-user file containing entries describing commands to execute and the time to execute them.

lexxwernAuthor Commented:
Sorry about that abandoning .. work is tough :(( :((
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.