Creating Backup Schedule in RHEL 5:
- Open Putty
- Login to the server (entering server IP)
- Login to server using user name and password from the Putty SSH Console
- To create a CRON schedule type:crontab –e <enter>
- VI text editor will open as a blank file for the “crontab entries” to be entered; each line represents a separate crontab entry (hereafter referred to as “CRON JOBS”).
- Each CRON JOB has at least 6 sections. Each section is delimited by a single blank space, but the final section may have spaces within it. No spaces are allowed within Sections 1-5, blank spaces are allowed only between those sections. Sections 1-5 are to indicate when and how often you want the task (the sixth position) to be executed and it uses the system time for execution.
- Here is how positions 1-5 are laid out:
1 Minute 0-59
2 Hour 0-23 (0 = midnight)
3 Day 1-31
4 Month 1-12
5 Weekday 0-6 (0 = Sunday)
An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used.
- Backup script within the crontab entry is
* 14 * * 5 root tar czpvf /home/user/backup-$(date +%Y-%m-%d).tar.gz /opt/lampp
- The CRON is set to 1400 hour (2:00 p.m.) 5th day of week (Friday)
- The command that will execute is
tar czpvf /home/user/backup-$(date +%Y-%m-%d).tar.gz /opt/lamppThis above command will tar the entire content of the directory /opt/lampp and put the tar file into /home/user/
The name of the tar file will be backup-$(date +%Y-%m-%d).tar.gz (backup-YYYY-MM-DD.tar.gz)
Leave a Reply