Skip to content

M7s3c7/CS1111

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Backup Script

The script can make backup of files in <src> directory which have vowels in their name into <dest> directory maintaining the directory structure as seen in the <src> directory.

Crontab running

To run this script exactly at midnight 12 everyday, we are going to add a Cronjob for the user who is backing up the files.

   0 0 * * *  ./backup_script.sh -s <src> -d <dest> -o <output>

The above command adds a Cronjob for the user, which runs the backup_script.sh automatically at midnight 12.

Working

The script takes arguments of the source directory, destination directory and also the output csv file. The script backup_script.sh goes through all the files in the <src> directory recursively using find command with the help of flags -type f for only files and -name for only name of the file to be checked for regular expression. Using sed, we create the required destination path to the backup file and check if the source file is newer than the backup file, if it exists. If the backup file doesn't exist then the -nt test automatically detects that. Now cp command gets executed when it is new and the required file is backed up.
The file keeps track of the count of the number of files copied and the time taken is calculated using date command. $$ gives PID of the process. We output all of these into the output file in CSV format. The time for running the script is in milliseconds.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages