#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.3 #Date: 19-01-2007 / 19-01-2008 / 2008-12-21 #System: Ubuntu/Debian GNU/Linux #Information: man unrar, man par2, man file #Category Thunar scripts #Name: Backup File(s) #Description: Backup selected items #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/file-backup %F #Patterns: * #Directories: True #Audio Files: True #Image Files: True #Text Files: True #Video Files: True #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Backup File(s)" DESCRIPTION=$"Backup selected items" location="/media/disk/backup/" location+=$(date +%Y-%m-%d-%H%M%S) # ":" does not work on fat32 cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" disk_busy_scan() { seconds=0 file="$HOME/.scripts/thunar/.diskbusy.txt" while [ -e "$file" ] do /bin/echo -e $"disk is busy, scanning $seconds please standby..." seconds=$(($seconds+15)) /bin/sleep 15 done } disk_busy_set() { if [ ! -d $HOME/.scripts/thunar ] then mkdir --parents $HOME/.scripts/thunar fi file=$HOME/.scripts/thunar/.diskbusy.txt touch "$file" trap "rm -f $file" 0 1 2 3 15 echo $"diskbusy: $file indication set" } disk_busy_unset() { file="$HOME/.scripts/thunar/.diskbusy.txt" rm -f "$file" echo $"diskbusy: $file indication unset" } cecho "green" $"processing:" for I in "$@" do echo "$I" done cecho "green" $"backup location:" echo "$location" cecho "green" -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi echo "---------------" for I in "$@" do cecho "green" $"starting: " disk_busy_scan disk_busy_set filename="$I"; filename=${filename##*/}; filename="${filename%.*}" unset permission if [ ! -w "$I" ] then permission="sudo" fi if [ ! -d "$location" ] then cecho "green" $"creating the backup location" $permission mkdir -v -m 0777 -p "$location" fi if [ -d "$location" ] then cecho "magenta" -n $"backup item from:" echo "$I" cecho "magenta" -n $"backup item to:" echo "$location/$filename.tar" cd "$location" $permission tar --create \ --preserve-permissions \ --preserve-order \ --absolute-names \ --force-local \ --totals \ --verify \ --file="$filename.tar" \ "$I" fi if [ $? -eq 1 ] then cecho "red" $"error processing $filename, continue after 15 seconds" sleep 15 continue fi disk_busy_unset cecho "green" $"completed:" echo "---------------" done cecho "green" -n $"finished, please press the [enter] key to close and exit this window" read input exit #filename=${I##*/} #foo=/media/usbdisk/bac.kup/foo.tar.gz; foo=${foo##*/}; [[ $foo = *.tar.gz ]] && echo $foo || echo ${foo%.*} #mkdir "2007-01-18 13:28"; cd "2007-01-18 13:28"; touch "2007-01-18 13:28.txt"; cd ..; filename="2007-01-18 13:28"; tar --create --preserve-permissions --preserve-order --absolute-names --force-local --totals --verify --file="$filename.tar" "$filename"