Backing up the current directory with shell script arguments and variables
One of the most common reasons why system engineers use Bash shell scripting is for backup purposes. There are various tools available, but for shell scripting purposes, we are going to make a couple of tar
-based shell scripts, work with arguments and variables, and learn how to make our jobs easier by using shell scripting for backup purposes. Let's take a look!
Getting ready
Before you start this recipe, you need to make sure that you have tar
installed on your Linux machine. For this, you need to use the following command:
sudo apt-get -y install tar
If you're using a CentOS-based machine, use the following command:
sudo yum -y install tar
Now, you're ready to get started.
How to do itβ¦
Our premise for this first backup script, which is based on tar
, is simple:
- We want to be able to create a backup while using an argument to set the backup's filename...