I have noticed that there aren't any good autobackup utilities for Linux, or any at all for that matter.
So i am willing to give you the one i made and have been using. For your enjoyment and to make it easy for you i have made it as noob friendly as possible as well as add extra features that weren't there originally but are very handy to have.
This has been coded in Bash and so will not require any extra packages to be installed to execute it.
For those who have read or can't be bothered to read below. Here is the quick brief version (Just copy and past)
[*:26f0yefh] Autobackup using the systems built in crontab and tar archiver.
[*:26f0yefh] Autosaves before backup.
[*:26f0yefh] Will notify you in game when a backup is progress and is completed. (Can be disabled with NOTIFY variable)
[*:26f0yefh] Auto installs the cronjob required (this can be enabled/disabled by a setting)
[*:26f0yefh] Will delete backups older than the specified amount of days
[*:26f0yefh] If you change the update interval it will auto update the cronjob for you. (Each time you change it you must execute the script manually and it will update the cronjob with the new interval)
<s> = String which must always be within quotes. eg. "Hi There" <n> = Number, should always and only ever be a number (Which shouldn't be within quotes like a string is) <c> = Command, This executes a system command and the output is to be saved in the variable. (I don't advise anyone to edit these kind of variables unless you know what you are doing.)
[*:26f0yefh] STAMP="<c>" - This is just the datetime stamp used when name the backup files. I wouldn't advise changing it but you can if you want. (the backups use the following format: "$WORLD.$STAMP.tar.gz" where $WORLD is the level-name value in your server.properties.)
[*:26f0yefh] SCREENNAME="<s>" - This is required by autosave so it knows where to send the save-all command. (requires screen, and for the server to be started as a screen session.)
[*:26f0yefh] AUTOSAVE=<n> - This is whether autosave is to be enabled or not. For it to work you must have 'screen' installed and must run the server in a screen session.
[*:26f0yefh] NOTIFY=<n> - Enable/Disable in-game notifications.
[*:26f0yefh] BACKUPDIR="<s>" - This is the name of the backup dir that will be created for you in your server directory.
[*:26f0yefh] PROPFILE="<s>" - This is the name of your servers properties file that contains the variable "level-name", which is needed to know which world is to be backed up.
[*:26f0yefh] CRONJOB=<n> - This is the toggle for the CronJob manager i did. Enabled it will auto install and update the cronjob needed for it to run every so often. Disabled, being able to disable it is so that if your host doesn't allow users to use crontab, you won't keep getting stupid messages saying that you can't. Also if the host provides a control panel where you can add cronjobs, then make sure this is disabled ( set to 0 ) and add it manually.
[*:26f0yefh] MAILTO="<s>" - Set this to your email address if you want to be sent notifications whenever there is an error with the script.
[*:26f0yefh] UPDATEMINS=<n> - This is how often (in minutes) you want the script to do backups. Hourly = 60, Daily = 1440.
[*:26f0yefh] OLDBACKUPS=<n> - This will tell the script how old the backups must be before removal. Default is 3 days.
[*:26f0yefh] LOGIT=<n> - This will Enable/Disable the scripts logging. Enabled it will tell what it is doing step by step. Disabled it will do quiet execution. (Enabling this is recommended when debugging)
[*:26f0yefh] Linux - LoL
[*:26f0yefh] (OPTIONAL) If you wish to use the autosave feature you must install 'screen' if you haven't got it already, and of course run the server in a screen session. For help with screen sessions go here: http://www.minecraftforum.net/viewtopic.php?f=10&t=36367
Installation is as simple as i could get it.
First we will use 'wget' to fetch the file, which find to be the best and quickest way.
Check if you have wget by doing
If you have it you will get spammed with some version crap, if you don't and instead get "command not found" then do the following to install it.
#As root user you can do the following
#For systems that use 'yum'
yum install wget
#For systems that use 'aptitude'
apt-get install wget
#If you have sudo installed then of course do the following
#For systems that use 'yum'
sudo yum install wget
#For systems that use 'aptitude'
sudo apt-get install wget
Now 'cd' to your server directory where you can see your minecraft server file. And do the following
Make sure that you edit the settings after downloading
Extra Info: Only rename the file if you know how to edit the cronjobs, as you will need to rename/remove the cronjob, then rename the file and then execute the file to add the new cronjob (I may do a way that sees the name change and updates accordingly for those who don't know how to edit cronjobs).
# DateTime stamp format that is used in the tar file names.
#Default stamp is DD-MM-YYYY_HHMMSS
# The screen session name, this is so the script knows where to send the save-all command (for autosave)
# Whether the script should tell your server to save before backup (requires the server to be running in a screen $
# Enable in-game notifications
# Backups DIR name (NOT FILE PATH)
# MineCraft server properties file name
# Enable/Disable (0/1) Automatic CronJob Manager
# When an error occurs it will send it to this e-mail
# Update every 'n' Minutes
# Delete backups older than 'n' Days
# Enable/Disable Logging (This will just echo each stage the script reaches, for debugging purposes)
If people show interest in this i will keep working on it and improve it more, maybe even recode it to another language to allow me to do even more features.
I know there isn't a screen not the issue, I can't see the errors with screen terminating itself :tongue.gif:
Its the tar errors I don't understand. Might be an easy fix I'm new to anything to do with unix.
Can you post an ls or tree of the directory. I use my own script but I think it needs to be run in the same directory as the 'world' directory not inside the 'world' directory. So just cp or mv the file or cd into that directory and download it again.
First off, don't run the server as the root user. On windows it wouldn't matter too much, but on Linux it is very bad for security.
Secondly yes it seems it can't find the folder for some reason. Perhaps when it tars the script is executing in a different directory? Which would be something that i can fix, but otherwise i don't see why it can't see it.
To stop the screen error popping up just set AUTOSAVE to 0. For the Autosave to work the game server has to be in a screen session and you have to put the screen name into the SCREENNAME variable in the config.
Can you do the 'ls -alh' in the server directory?
Please update the script and then enable the logging feature and post the output.
Thanks for writing this script, it looks good! I do have one question, when I started the script it said something about "no cron file" three times, but everything appears to be working. Is that normal?
ps: oops, it looks as if it can not create a cron job unless you have admin powers, unless I am reading the errors wrong
pps: switched from centos to ubuntu, everything seems ok except I get the "world changed as I read it" message. Is this a big deal? If so, how do I fix it?
you could just copy the line where it sends save-all to the console and paste one before and after it.
The one before should be 'save-off' and the one after to be 'save-on'. Basically the world is still saving while it is backing up.
I have re-written this into PHP anyway and is much better, as well as less resource hungry, i will release a public version of it when i get home in a few days. I have also written a PHP server wrapper that works with it too that i will release probably next week.