Creating a poor man's incremental remote backup
In this recipe, we will learn about creating backups and incremental backups. We will write a script to get incremental backups.
Getting ready
Besides having a Terminal open, we need to remember a few concepts:
- Basic knowledge of theÂ
tar,gunzip, andÂgzipcommands. - Ensure that you have the necessary directories present in your system.
How to do it…
- First, select a directory whose backup you want to take. We will use theÂ
tarcommand. Let's assume that you want to take backup of your/workdirectory:
$ tar cvfz work.tar.gz /work- Now, we will write a script to take an incremental backup. Create a
incr_backup.shscript and write the following code in it:
#!/bin/bash gunzip /work/tar.gz tar uvf /work.tar /work/ gzip /work.tar
Â
Â
Â
Â
How it works…
Now, we will learn about the options used in the preceding command as well as the script:
- In the command, the options we have used are these:
c: This option will create an archivev: This option is for verbose mode. We...