• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

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?

Thanks!
0
lexxwern
Asked:
lexxwern
1 Solution
 
ahoffmannCommented:
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.
0
 
Sam PanwarSr. Server AdministratorCommented:
Hi,

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.
0
 
rama_krishna580Commented:
Hi,

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 .

http://www.debianhelp.co.uk/schedulejobs.htm

R.K
0
 
rama_krishna580Commented:
Hi,

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:

/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly

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.

R.K
0
 
lexxwernAuthor Commented:
Sorry about that abandoning .. work is tough :(( :((
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now