I need a little help making a bash script for backing up my world for my server to use the essentials backup option in the config file i ahve tryed
#!/bin/bash
# Set these values to match your server's settings.
# This script should be located in the craftbukkit folder
# Make sure you change this to the name of your world folder!
# Add additional worlds by separating them with a space.
declare -a worlds=(world world_nether)
backupdir=backups/
ext=.zip
hdateformat=$(date '+%Y-%m-%d-%H-%M-%S')H$ext
ddateformat=$(date '+%Y-%m-%d')D$ext
numworlds=${#worlds[@]}
echo "Starting multiworld backup..."
if [ -d $backupdir ] ; then
sleep 0
else
mkdir -p $backupdir
fi
zip $backupdir$hdateformat -r plugins
for ((i=0;i<$numworlds;i++)); do
zip -q $backupdir$hdateformat -r ${worlds[$i]}
echo "Saving '${worlds[$i]}' to '$backupdir$hdateformat'."
done
cp $backupdir$hdateformat $backupdir$ddateformat
echo "Updated daily backup."
find $backupdir/ -name *H$ext -mmin +1440 -exec rm {} \;
find $backupdir/ -name *D$ext -mtime +14 -exec rm {} \;
echo "Removed old backups."
echo "Backup complete."
exit 0
and this is what i get
/Desktop/Server$ bash backup.sh
backup.sh: line 3: $'\r': command not found
backup.sh: line 5: $'\r': command not found
backup.sh: line 8: $'\r': command not found
backup.sh: line 12: $'\r': command not found
backup.sh: line 16: $'\r': command not found
Starting multiworld backup...
backup.sh: line 18: $'\r': command not found
backup.sh: line 25: syntax error near unexpected token `$'do\r''
'ackup.sh: line 25: ` for ((i=0;i<$numworlds;i++)); do
i would just like a simple one that would zip it with commpression move it to backups as long with the name of day and time
i dont mind deleteing old back ups my self
I unfortunately don't code in bash, but sadly I'm a pretty big Linux user and a plugin developer. I should probably look over the syntax
I can't really help you, and I don't think many people use Linux here, much less write scripts in bash. You will probably have better luck in a Linux forum, or even better, a forum dedicated to Bash scripting.
The "\r", which is the return line with Windows, seems to be affecting the file, which is a bit odd since I have not had issues using scripts made on a Windows machine, although the file encoding might have done that.
Have you tried using the "vi" function in Linux to make this file?
Can we also have a download of the file as well? So we can see it in the form you have it in?
The "\r", which is the return line with Windows, seems to be affecting the file, which is a bit odd since I have not had issues using scripts made on a Windows machine, although the file encoding might have done that.
Have you tried using the "vi" function in Linux to make this file?
Can we also have a download of the file as well? So we can see it in the form you have it in?
Thanks for your comment I figured it out because of you what was wrong was that since I has first saved it in notepad in windows is that it wasn't in UNIX formating like you said it was saving in windows format all I did was change it to UNIX file ending and it works fine now thanks for the reply guys
and this is what i get
i would just like a simple one that would zip it with commpression move it to backups as long with the name of day and time
i dont mind deleteing old back ups my self
thanks for any help
I can't really help you, and I don't think many people use Linux here, much less write scripts in bash. You will probably have better luck in a Linux forum, or even better, a forum dedicated to Bash scripting.
Have you tried using the "vi" function in Linux to make this file?
Can we also have a download of the file as well? So we can see it in the form you have it in?
Thanks for your comment I figured it out because of you