Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #/#/ Define any tools needed here seperated only by a "\:space:"\
- needed_tool=' yad rsync tar '
- #//* Begin System Tool Search
- require_tools ()
- {
- local NOT_AVAIL=""
- for TOOL in $needed_tool; do
- if [ "`which $TOOL`" 2> /dev/null == "" ]; then
- NOT_AVAIL="$NOT_AVAIL $TOOL";
- fi
- done
- if [[ "$NOT_AVAIL" != "" ]]; then
- echo "ERROR: The following required tool(s) cannot be found: $NOT_AVAIL"
- exit 3
- fi
- }
- # Check file system tools before we start
- require_tools || exit 1
- # VARIABLES
- THIS_DIR=$PWD/TMP_BKUP
- MK_DIR=$(mkdir $THIS_DIR)
- FILE=./backup.$(echo $RANDOM).tar
- DESTIN="$(yad --title "Choose Direcotory To Backup" --file-selection --directory)"
- # PREPERATION
- $MK_DIR
- # ADDING FILE TO ARCHIVE
- rsync -vrhu --append-verify --progress "$DESTIN" "$THIS_DIR"
- echo -e "Files copied to temporary directory; press [E]nter to create compressed archive and remove the temporary directory: "
- read NULL
- # COMPRESS BACKUP AND REMOVE FILES
- tar -vcf $FILE --remove-files "$THIS_DIR"
- echo -e "\nCompressed archive backup file has been created.\nPress [E]nter to cleanup and finish: "
- read NULL1
- # FINISH
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement