I made a save script, to save some directories in my /home. To do that I loop through the directories in /home, and launch a save for each of them.
These directories contain jar files, and some .txt. Properties and other directories. The first time I launch the script it worked great. I modified it, but yesterday when I try some feature it goes wrong and I can not find why.
I have this error when I use the tar -cjf command to create .tar.zip archive.
tar: home/myFolder : impossible stat: no file or folder of this type
backupdate=$(date +%Y-%m-%d)
dirbackup=/save/$backupdate
mkdir $dirbackup
list_dossier=`ls ../home`
for server in $list_dossier
do
tar -cjf $dirbackup/$server.tar.zip home/$server
done
EDIT
I'm trying to keep this shape of save : a folder with name the date, and in it, X archves contain my X folders of my /home
#!/bin/bash
backupdate=$(date +%Y-%m-%d)
dirbackup=/save/$backupdate
mkdir $dirbackup
for server in /home/*
do
echo $server"test"
tar -cjf $dirbackup$server.tar.zip $server
done
exit
forstatement. There ought to be a;(or a newline) beforedo. Also, you are much better off iterating over/home/*/, as infor serverpath in /home/*/; do server=$(basename "$serverpath"); tar ... "$serverpath"; doneor something like that.ls ../homeresults if the files listed have whitespace in their names, or newline characters etc.. consider feeding your for loop (or a while loop) a list of null separated results instead.doin my code was one line below, I have edit as my code is ^^ Ok for the/home/*/and yes you right @JeffH.I have a space after the server name !homeshould be/home.