In this recipe, we will learn about creating backups and incremental backups. We will write a script to get incremental backups.
Besides having a Terminal open, we need to remember a few concepts:
- Basic knowledge of the
tar
,gunzip
, andgzip
commands. - Ensure that you have the necessary directories present in your system.
- First, select a directory whose backup you want to take. We will use the
tar
command. Let's assume that you want to take backup of your/work
directory:
$ tar cvfz work.tar.gz /work
- Now, we will write a script to take an incremental backup. Create a
incr_backup.sh
script and write the following code in it:
#!/bin/bash gunzip /work/tar.gz tar uvf /work.tar /work/ gzip /work.tar