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.
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 .
1.cd ~ or cd command.
Step 3: Create New Shell Script File.
Create New Shell script file for write script.Use Following Commands.
1.vim backup.sh or nano backup.sh
As you know,Linux shell script file's extention is '.Sh'.
Step 4: Enter Followinng Script.(backup.sh)
#~/bin/bash
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 backup.sh
Step 6: Rename Script File.
Now it's time to convert your file in to commands.
follow command as below.
1.mv backup.sh your-command-name
done.
Now Check Files in current folder using ls command.
Your renamed file convert into green color.
Perfect!!!
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
1.mv your-command-name /bin
2.mv your-command-name /sbin
To Copy,Follow this command
1.cp your-command-name /bin
2.mv your-command-name /sbin
You have Done !!!
Comments
No Comments Exist
Be the first, drop a comment!