last day (14 days later) » 

06:51
0
Q: svn backup bash script errors

K.K PatelI have created bash script for create dump of svn repositories. I want to add such functionality that after dump of every repository script send it to remote server using rsync and delete from dump location and after that starts to make dump of next repository. I am using following script. scrip...

slm
slm
What are the errors? Please add them to your question, otherwise it's difficult to tell what you're getting stuck on.
./backup.sh: line 55: syntax error near unexpected token <code>fi'
./backup.sh: line 55: </code> fi'
slm
slm
That error is pretty self explanatory. You're missing a closing fi for one of your if blocks.
I am also getting error after adding fi
slm
slm
OK, can you share them?
06:51
./backup: line 55: syntax error near unexpected token <code>fi'
./backup: line 55: </code> fi '
slm
slm
Your for loops are missing done at the end.
I am new to bash script require help.
slm
slm
OK.
Did you add the keyword done after the for loops?
my current script
#!/bin/sh

# Record todays date
# --------------------
bakdate=$(date +%Y-%m-%d)
echo "--------------------------------"
echo "Running SVN backup $bakdate"
echo "--------------------------------\n"

# From where to backup repos?
# ---------------------------
svnrepos="/avinashi/svn/"
echo "\nGoing to backup all SVN repos located at: $svnrepos \n"

# Where to save the dump?
# ------------------------
bakdest="/store/"

# Location of remote server (to copy backup)
# ----------------------------------------
slm
slm
or repo in *; do
# do svn dump for each project
echo "Taking backup/svndump for: $repo"
echo "Executing : svnadmin dump $repo >
$bakdest/$repo-$bakdate.dump \n"
# Now finally execute the backup
svnadmin dump $repo > $bakdest/$repo-$bakdate.dump
done
Sorry didn't copy it all
for repo in *; do
# do svn dump for each project
echo "Taking backup/svndump for: $repo"
echo "Executing : svnadmin dump $repo >
$bakdest/$repo-$bakdate.dump \n"
# Now finally execute the backup
svnadmin dump $repo > $bakdest/$repo-$bakdate.dump
done
for repo in *; do
# do svn dump for each project
echo "Taking backup/svndump for: $repo"
echo "Executing : svnadmin dump $repo >
$bakdest/$repo-$bakdate.svn.dump \n"
# Now finally exec/mnt/Earthpool/servers/takeute the backup
svnadmin dump $repo > $bakdest/$repo-$bakdate.dump

# sent it to remote server

rsync -avP $bakdest/$repo-$bakdate.dump $baktoremote
done
for loops are like this:
for repo in *;do
blah
blah
blah
done
if statements are like this:
if [ -d "somedir" ]; then
blah
blah
fi
06:59
this gives me ./google: line 57: syntax error: unexpected end of file
slm
slm
paste what you have now (the whole script) please
Checkout whole script ./google
--------------------------------
Running SVN backup 2013-04-17
--------------------------------\n
\nGoing to backup all SVN repos located at: /avinashi/svn/ \n
./google: line 57: syntax error: unexpected end of file
[root@anant ~]# nano google
[root@anant ~]# cat google
#!/bin/sh

# Record todays date
# --------------------
bakdate=$(date +%Y-%m-%d)
echo "--------------------------------"
echo "Running SVN backup $bakdate"
echo "--------------------------------\n"
slm
slm
One other thing, if you're going to use echo and include '\n' within it, you have to tell echo to interpret those at carriage returns by calling it with the '-e' switch, something like this:
echo -e "\nhi how are you\n"
You only added a single done to the script, it needs 2 because you have 2 for loops
slm
slm
you also didn't add the fi line that I mentioned
for the if blocks
07:06
oh , I think that done is replacement of fi.
Please provide me final script
slm
slm
I'm not here to do, here to teach
you might want to read about bash scripting if you're going to be doing a script like this

last day (14 days later) »