Forum Thread: How to Make Your Own Command to Backup in RedHat Linux?

How to Make Your Own Command to Backup in RedHat Linux?

Hello Friends,currently I'm student of RHCSA.I want to share script that i have written in my lab for backup and restore.Let's Start.

Image via

Backup of Folder

Generally,We use 'tar in linux for backup/restore.Let's start scrpit.

Step 1: Open Temrminal.

Open Terminal of Your Linux from Right Click>Open Terminal.

Step 2: Go to Root Directory.

go to root directory for make it easy . ~ or cd command.

Step 3: Create New Shell Script File.

Create New Shell script file for write script.Use Following Commands.
1.vim or nano
As you know,Linux shell script file's extention is '.Sh'.

Step 4: Enter Followinng Script.(

echo "Script By : Yourname
echo "Enter Folder Name/Path:";
read path;
echo "Enter Backup(tar) File Name";
read fname;
echo "Where do You Wand to Store Your Backup File:"
read bpath

tar -cvf $path $fname.tar
mv $fname.tar $bpath

Step 5: Give Execution Permission to Your File.

You must have to give execution for script.
follow this command to give execution permission.
1.chmod o+x

Step 6: Rename Script File.

Now it's time to convert your file in to commands.
follow command as below. your-command-name
Now Check Files in current folder using ls command.
Your renamed file convert into green color.

Step 7: Move Your Renamed File into /Bin and /Sbin.

For Make Your file into command,you have to move/copy your created file in/bin and /sbin folder.

To Move,Follow this command your-command-name /bin your-command-name /sbin
To Copy,Follow this command
1.cp your-command-name /bin your-command-name /sbin

You have Done !!!

2 Responses

I'm already using something like this on Kali, although this could seem a little Out Topic, it's always useful to have ready backups ;) !

Welcome to Null Byte!

Share Your Thoughts

  • Hot
  • Active