The loss of important data can mean fatal damage. Still, countless professionals are ignoring the backup of their data. Although the reasons may vary, one of the most common explanations is that performing routine backups is really cumbersome. Because machines are adept at accomplishing common and repetitive tasks, automating the backup process is key to reducing the intrinsic tedium of work and the propensity for procrastination that people are born with.
If you use Linux, you can already use extremely powerful tools that create customized backup solutions. The scenarios in this article allow you to perform a simple to more advanced and secure network backup with an open source tool that comes with almost every Linux release.
Simple backup
This article is described in a step-by-step way, and this approach is straightforward as long as you follow those basic steps.
Before we look at more advanced distributed backup solutions, let's start with a simple and powerful archiving mechanism. Let's analyze a handy script called arc, which allows us to create a backup snapshot in the Linux shell prompt.
Listing 1. Arc Shell Script
#!/bin/sh
tar czvf $1.$ (date +%y%m%d%-h%m%s). tgz
$?
The arc script receives a separate file or directory name as a parameter, creates a compressed archive file, and embeds the current date into the name of the generated archive file. For example, if you have a directory named Beoserver, you can call the Arc script and pass the Beoserver directory name to it to create a compressed archive file, such as: beoserver.20040321-014844.tgz
The date command is used to embed a date and time stamp to help you organize your archived files. Dates are in the format of year, month, day, hour, minute, and second-although there is some redundancy in the use of the second field. Look at the manual for the data Command (man date) for additional options. In addition, in Listing 1, we passed the-V (verbose) option to tar. This allows tar to display the files it is archiving. If you prefer to make backups silently, delete this-v option.
Listing 2. Archive Beoserver Directory
$ ls
arc beoserver
$./arc beoserver
beoserver/
beoserver/bookl.dat
beoserver/beoserver_ab_o FF
beoserver/beoserver_ab_on
$ ls
arc beoserver beoserver.20040321-014844.tgz