How to do it…

  1. 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
  1. 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/bashgunzip /work/tar.gztar uvf /work.tar /work/gzip /work.tar

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.