1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/bin/bash ZIPPER=/usr/bin/7z COPY=/bin/cp MOVE=/bin/mv ## MODIFY ## ARCHIVEDIR=/mnt/data/archives ############ zipIt(){ echo "executing $ZIPPER a -t7z -mx9 -v1g $ARCHIVEDIR/$FILE.7z $PATH" $ZIPPER a -t7z -mx9 -v1g $ARCHIVEDIR/$FILE.7z $PATH } if [ -z $1 -o -z $2 ]; then echo "Usage: archive.sh {relative or absolute directory name} {archive name}" exit 1 fi if ! [ -d $1 ]; then echo "directory $1 not found!" exit 1 fi PATH=$1 FILE=$2 echo "archiving $PATH to $ARCHIVEDIR/$FILE.7z" zipIt if ! [ $? = 0 ]; then echo "error while zipping" exit 1 fi; echo "all done!" exit 0 |
Use this script to archive directories with 7zip (wont work for files).