I am very new to this shell scripting and bacula. I want to create a script that schedules the backup using bacula?
How to do that?
Any lead is appreciated?
Thanks.
I don't think it gives meaning to have a cron scheduled script to activate Bacula.
The standard way to schedule backup using bacula is : 1) Install the Bacula file daemon on the machine you want to backup and then 2) Configure your Bacula Directory to schedule the backup
ad 1) If your machine to backup is Debian or Ubuntu, you can install the Bacula file daemon from the shell like this: shell> apt-get install bacula-fd (bacula-fd stands for Bacula File Daemon) If your machine to backup is Windows, then you need to download the Bacula file daemon and install it. You can download here : http://sourceforge.net/projects/bacula/files/Win32_64/ (select the version that match your Bacula server version)
ad 2) You need to find the bacula-dir.conf file on your Bacula server (if you installed Bacula Director on a Ubuntu machine, then the path is : /etc/bacula/bacula-dir.conf) The bacula-dir.conf schedule section is very flexible and therefore also somewhat complicated, here is an example :
Schedule {
Name = "MonthlyCycle"
Run = Level=Full on 1 at 2:05 # full backup the 1. of every month at 2:05.
Run = Level=Incremental on 2-31 at 2:05 # incremental backup all other days.
}
Note that there are a lot more configuration necessary to run Bacula, here is a full tutorial how to install, configure, backup and restore Bacula : http://webmodelling.com/webbits/miscellaneous/bacula.aspx (disclaimer : I wrote the Bacula tutorial myself)
If you are going to administer your own Linux system, learn
bash
. Theman
page is really quite detailed and useful. Doman bash
.If you are really new to Linux and command-lines, administering
bacula
is not for newbies. It is a fairly comprehensive backup system, for multiple systems, with a central database, which means that is is also complex.There are much simpler tools available on Linux to perform simple system backups, which are just as reliable. If you just want to backup you home directory,
tar
orzip
are excellent tools. In particular,tar
can do both full backups and incremental backups.Assuming that you really want to use
bacula
and have enough information to write a couple of simple scripts, then even so, the original request is ambiguous.Do you mean schedule a periodic
cron
job to accomplish backups unattended? Or, do you mean to schedule an single invocation ofbacula
at a determined time and date?In either case, it's a good idea to create two simple scripts: one to perform a full backup, and one to perform an incremental backup. The full backup should be run, say, once a week or once a month, and the incremental backup should be run every day, or once a week -- depending on how often your system data changes.
Most modest sites undergoing daily usage would have a daily incremental backup with a full backup on the weekends (say, Sunday). This way, if the system crashed on, say, Friday, you would need to recover with the most recent full backup (on the previous Sunday), and then recover with each day's incremental backup (Mon, Tue, Wed, Thu). You would probably lose data changes that had occurred on the day of the crash.
If the rate of data change was hourly, and recovery at an hourly rate was important, then the incrementals should be scheduled for each hour, with full backups each night.
An important consideration is knowing what, exactly, is to be backed up. Most home users want their home directory to be recoverable. The OS root and application partitions are often easily recoverable without backups. Alternatively, these are backed up on a very infrequent schedule (say once a month or so), since they change must less frequently than the user's home director.
Another important consideration is where to put the backups.
Bacula
supports external storage devices, such as tapes, which are not mounted filesystems.tar
also supports tape archives. Most home users have some kind of USB or network-attached storage that is used to store backups.Let's assume that the backups are to be stored on
/mnt/backups/
, and let's assume that the user's home directory (and subdirectories) are all to be backed up and made recoverable.Once this script is configured and available, it can be scheduled with
cron
. Seeman cron
. Usecron -e
to create and edit a crontab entry to invokefull-backup
once a week (say), and another crontab entry to invokeincr-backup
once a day. The following are three sample crontab entries (seeman 5 crontab
for details on syntax) for performing incremental and full backups, as well as removing old archives.Recovering from these backups is an exercise left for later.
Good luck.