Search This Blog

Sunday, October 1, 2023

Shell script 14

Question: Backup the important files and directory's with the timestamp

Answer:

#!/usr/bin/bash

#source directory to back

source_dir="/home/kalam/raju"

#backup directory

backup_dir="/home/kalam/Professor"

#creating the timestamp for the backup

timestamp=$(date +"%Y%m%d%H%M%s")

backup_sub_dir="$backup_dir/backup_$timestamp"

mkdir -p "$backup_sub_dir"

rsync -av "$source_dir/" "$backup_sub_dir/"


Output:

kalam@DESKTOP-OSJTLNE:~$ sh back_up_dir_files.sh

sending incremental file list

./

sent 58 bytes  received 19 bytes  154.00 bytes/sec

total size is 0  speedup is 0.00

kalam@DESKTOP-OSJTLNE:~$ ls Professor/

backup_2023100120341696172680  backup_2023100120341696172691  backup_2023100120351696172717  backup_2023100120381696172901

No comments:

Post a Comment

What is the sanity checks you have done for STA?

 Sanity checks for STA: Linking Checks: We need to check., is there any missing modules or missing pins in a library. this is done by link c...