Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # name for backup file created
- FILENAME=backup-$(date +%-Y%-m%-d)-$(date +%T).tgz
- # user defines directory to backup (aka: source path)
- echo "Path of directory to backup?"
- # path to directory variable
- read -r SRCDIR
- # user defines backup destination
- echo "Where would you like the backup saved?"
- # get backup destination variable
- read -r DESTDIR
- # verify before committing to backup operation
- while true;
- do
- read -rp "Backup?: $SRCDIR " yn
- case $yn in
- [Yy]* ) tar czf "$FILENAME" "$SRCDIR" "$DESTDIR";;
- [Nn]* ) exit;;
- * ) echo "Please answer yes or no.";;
- esac
- done
- echo "Backup Complete"
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement