Bash backup wont work -
i'm trying gzip file using script not work , continues throw errors. can please giveme guidance on wrong script?
defaultdirectory=”/backup” if [ -d "$defaultdirectory" ]; mkdir -p /backup fi # makes directory if directory not exist # set timestamp backup timestamp=`date +%y%m%d.%h%m` # let user choose want backup echo -n "select file or directory want backup" read chosendata # read backup file name file echo -n "select file name" read fname # start backup. echo -e "starting backup" # compress directory , files, direct tar.gz file destination directory tar -vczf ${fname}-${timestamp}.tar.gz ${chosendata} > ${defaultdirectory} # end backup. echo -e "backup complete"
redirecting output tar command defaultdirectory
isn't doing comment specifies.
i think want save file in defaultdirectory
.
change line
tar -vczf ${fname}-${timestamp}.tar.gz ${chosendata} > ${defaultdirectory}
to
tar -vczf $defaultdirectory/${fname}-${timestamp}.tar.gz ${chosendata}
Comments
Post a Comment