February 13, 2017

Cron Job and TAR Combination for backup Apache Directory

Cron Job Function
Linux Command
If you working as System administrator (Sysadmin) this article related with your daily job to keep youd data safety. If you don't have a system backup such as Netbackup, Tivoli or another third party backup system. As system administrator you should create a backup manual. This article we will create a simple backup scrip for linux or Unix (i'm using Linux Ubuntu 14.04) combined tar and cron job.

Cron Job :

Cron Job allow system administrator to create a schedule or task and define by own sysadmin administrator needed. So we will learn first about cron job. The software default utility cron is a time-based scheduler in Unix like computer operating system. System admin can set up and maintenance this cron job. in Windows version it called Windows Task Scheduler. Cron job running periodically and fixed time based on system administrator needed. 

Cron handeled by a crontab file, in this configuration file contain some specifies shell command. This command combined with time schedule. The contab file store in the list of some job and contain shell script.

Each line of a crontab file represents a job, and looks like this:

 ┌───────────── minute (0 - 59)
 │ ┌───────────── hour (0 - 23)
 │ │ ┌───────────── day of month (1 - 31)
 │ │ │ ┌───────────── month (1 - 12)
 │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday;
 │ │ │ │ │                                       7 is also Sunday)
 │ │ │ │ │
 │ │ │ │ │
 * * * * *  command to execute

Tar :

The tar command on Linux is often used to create .tar.gz or .tgz archive files, also called “tarballs.” This command has a large number of options, but you just need to remember a few letters to quickly create archives with tar. The tar command can extract the resulting archives, too.

The GNU tar command included with Linux distributions has integrated compression. It can create a .tar archive and then compress it with gzip or bzip2 compression in a single command. That’s why the resulting file is a .tar.gz file or .tar.bz2 file.

Basic Command :
-c: Create New archive.
-z: Compress this archive gzip formated.
-v: Display the progress gzip compressed in the terminal,known as “verbose” mode.
-f: Allows you to chustom specify the filename of the archive.

For more example, i created a video tutorial for combined tar and cron job

Previous Post
Next Post

post written by: