tar-cron.php
build tar command-lines for use in cron

This web-page (tar-cron.php, actually it's a PHP program) is designed to help with the construction of tar command-lines for use in your cron and can be used for contemporal tar execution.

The tar program is an archiver tool.
The cron program runs scheduled jobs.




tar-cron.php program source
references (opens in new window)
tar --help   (may be dated)
tar: an archiver tool
cron manual page
crontab(5) manual page (describes time/date fields)
tar manual page
GNU tar: an archiver tool
BASH Programming - Introduction HOW-TO


tar-cron.php is free to use. Please enjoy.

Just Add Common Sense
You alone are responsible for your life.
Please use with wisdom.


TAR-CRON.PHP IS FOR PRIVATE USE ONLY.
COMMERCIAL USE OR REDISTRIBUTION IN ANY FORM,
PRINTED OR ELECTRONIC IS PROHIBITED.



Copyright 2003 John G. Derrickson   All Rights Reserved
JGD@freeVEDA.org
archive name (no dots, no extension)
archive directory (not in archived path)
shell file name (include the .sh extension)
directory path to be archived (may have several paths separated by spaces)
put current date into daily backup file name
use compression
make a log file (don't if MAILTO in cron)
hour   minute select time of day to run monthly tar in cron (allow time for tar to run)
hour   minute select time of day to run weekly tar in cron (allow time for tar to run)
hour   minute select time of day to run daily tar in cron (allow time for tar to run)
weekday select day of week to run weekly tar in cron
day of month select day of month to run monthy tar in cron

Click generate button and when page returns:
Copy-and-paste the shell lines and build the shell file.
Copy-and-paste the three command-lines into your cron file and run crontab.
 
generated command-lines
WARNINGS:
The "archive name" is empty -- not a good thing.
The "archive directory" is empty -- not a good thing.
The "directory path to be archived" is empty -- not a good thing.
The "shell file name" is empty -- now set to backup_.sh.

monthly generated command-line:
(a full backup)
10 0 1 * * tar -cvzSf /-monthly.tar.gz

weekly generated command-line:
(backup files changed since last monthly)
20 0 * * 0 tar -cvzS -N /-monthly.tar.gz -f /-weekly.tar.gz

daily generated command-line:
(backup files changed since last weekly)
30 0 * * * tar -cvzS -N /-weekly.tar.gz -f /-daily-`date +%Y%m%d`.tar.gz

all together:
for crontab:


for shell script backup_.sh:


web page to copy backup files from server to local computer:

Notes:

Be sure a weekly backup exists before making a daily backup and a monthly backup exists before making a weekly backup. So, to get the cycle started, run at the console command prompt the monthly command followed by the weekly command.

tar -cvzSf /-monthly.tar.gz

tar -cvzS -N /-monthly.tar.gz -f /-weekly.tar.gz


Copy-and-paste the shell lines and build the shell file.

Copy-and-paste the three command-lines into your cron file and run crontab.

For safekeeping, you should copy the archives from the server to another computer:
/-monthly.tar.gz
/-weekly.tar.gz
/-daily-*.tar.gz
(note: * is date as yyyymmdd)

You should inspect the log files e-mailed to you.

Be certain there is enough disk space to store the archive files. Don't try to backup all server files -- concentrate on directories that hold your web-page files and your program files.

Copyright 2003 John G. Derrickson   All Rights Reserved
modified Tuesday January 4, 2005   JGD@freeVEDA.org