Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- (echo "Back up files with the specified extension to the specified path to the specified folder: "
- echo -e "\t./backup source_files files_extension source_archive"
- echo -e "\tOnce buck up files"
- echo "Keys:"
- echo -e "\t-t or --time:\tSets period of backup in format:\n\tminute hour day month day_of_week\n"
- echo -e "\t-c or --count:\tSets count of backup\n\tIf count of backup bigger than the specified number\n\tdeletes the old backups (count - 1) and creates another backup\n"
- echo "Examples:"
- echo -e "\t./backup -t 0 * * * * source_files files_extension source_archive\n\tBackups files at the begginning of every hour\n"
- echo -e "\t./backup -c 5 source_files files_extension source_archive\n\tSaves no more than the 5 archives in source_archive\n"
- echo -e "\t./backup -tc * * * * * 5 source_files files_extension source_archive\n\tBackups files every minutes and saves no more\n\tthan 5 the archives in source_files")
- exit 0
- elif [ "$1" == "-t" ] || [ "$1" == "--time" ]; then
- touch config.txt
- echo $7 > config.txt
- echo $8 >> config.txt
- echo $9 >> config.txt
- crontab -r
- exit 0
- fi
- readarray -a settings < config.txt
- cd ${settings[2]}
- tar -cf archive.tar ${settings[0]}/*.${settings[1]}
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement