[INACTIVE][ADMN] Backup 1.6 - A simple Backup Plugin [818]

Discussion in 'Inactive/Unsupported Plugins' started by Meldanor, Mar 25, 2011.

  1. Offline

    Meldanor

    Important!
    I've stopped the development of this plugin, becase I lost the motivation. The user 'gamerx93' will continue my work in this thread:

    http://forums.bukkit.org/threads/admn-backup-v1-8-3-a-simple-backup-plugin-1392.39927/

    Backup - A simple Backup Plugin :
    Version : 1.6

    After I've searched for a simple, but powerfull backup plugin, I've tried some backups, but some have bugs, other don't save the world before they zip and so on. So I decided to write my own backup plugin.

    Features:
    • Automatically backups the server(all worlds) in a Intervall you've decided and zip it.
    • Saves every world running on the server and every player before the backup
    • Supporting Permission
    • Supporting manuel backups (you can use an ingame command or on the console)
    • Storing only a limit of backups that you've configure
    • You can set that only to backup when player are on the server
    • Stores also the plugin folder
    • Formate the date format
    Download:
    Source
    Plugin

    Changelog:
    Version 1.6:
    • Added option to control where the backups are getting stored
    • Fixed disabling broadcast messages
    • You can now use also the old save system, which is the same as before 1.5
    • Uses godsny's suggestion for the config file. Thanks !
    • Fixed bug deleting the custom dir when the maximum backup limit is hit!
    • Fixed bug stopping the complete backup if there is one file error!
    • Fixed bug not disabling the automatic backup when you set the BackupIntervall to -1
    Version 1.5:
    • Added property to also backup the plugin folder(is set to true by default)
    • Fixed issue with data corruption by using not thread save methods. Thanks to desmin88 for the hints!
    • All worlds(and when enabled the plugin folder) is stored in ONE ZIP
    • Customize the timestamp by merge a fork of xfxian . Thanks to xfxian!
    • You can now disable enabling the autosave (the command "save-on", not the backup cyclus!) by setting the property to true. It is false by default. Notify, that I will run the command "save-off" before I will start the backup to prevent unwished results!
    • When server is starting, the config.ini is checked now. If you don't have the current config.ini you can see on the console a error. Remove / relocate the config temporary to get the newest one.
    Show Spoiler

    Version 1.4a:
    • Fixed the bug " [Backup] Zipping backup is disabled! "
    Version 1.4:
    • Use ASyncMethod instead of SyncMethod (the lags should be gone)
    • Own broadcast messages ( change the message in you config.ini file)
    • A backup is run when the last player has left the server after the normal backup cyclus.
    • Remove worlds from backup (add the names of the worlds in your config.ini files)
    • Add an option to just store the worlds in dirs or zip them
    • Some minor improvements
    Version 1.3a:
    • You can now run a backup from the console using the command backup
    Version 1.3:
    • Implemented new function to only backup when player are online
    • Use Apache Common IO library instead of code from the internet for a better performance and better stability
    Version 1.2b:
    • Fixed bug with empty dirs
    Version 1.2a:
    • Fixed bug not creating config.ini
    Version 1.2:
    • Implement property so only ops can start manuell backups
    • Updated to recommened build 602
    • Tried to fix the problem with some system by using the system file seperator
    Version 1.1:
    • Added option to give manual backups a name(which will never automatically removed by auto backup)
    Version 1.0:
    • First release

    Install
    Just place it in your plugins dir

    Configuration
    Show Spoiler

    After the first start of the plugin it generates a config.ini in "plugins/Backup".
    Here is the current content:

    Version=1.6
    // --All variables are in minutes--
    // How often show the backup run? (#)
    // Notice: -1 Will disable automatic backups. You have to run the backups now manually!
    BackupIntervall=15
    // How many backups are retained? If this limit is hit, the oldest backup will be removed. (#)
    MaximumBackups=96
    // Only allow Ops to preform manual backups? (true/false)
    OnlyOps=true
    // Should backups only be preformed when there are players on the server?
    // Notice: When the last player leaves the server, a final backup will be made
    // within the backup cycle. The automatic backup cycle will resume when a player
    // joins. (true/false)
    BackupOnlyWithPlayer=true
    // Server broadcast message when starting a backup.
    // Notice : Remove the messages(not the property) to disable a broadcast. (text)
    MessageStartBackup=Start backup
    // Server broadcast message when a backup is completed.
    // Notice : Remove the messages(not the property) to disable a broadcast. (text)
    MessageFinishBackup=Finished backup
    // Worlds that should not be archived by the server, seperate them by
    // a semicolon. (directory names)
    // Example : World1;World2;Nether
    DontBackupWorlds=
    // ZIP backups?
    // If enabled, backups will be compressed and stored in a ZIP archive named with
    // the current timestamp.
    // If disabled, the backup will stored in a folder with the timestamp. (true/false)
    ZIPBackup=true
    // Custom date format string that is appended to every backup.
    // If left empty, the default date format is used.
    // This has to be a Java String.format string, see
    // http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax
    // for reference.
    // Example: -%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS (YYYYMMDD-HHMMSS: 20101201-011323) (conforms to ISO 8601)
    CustomDateFormat=%1$td%1$tm%1$tY-%1$tH%1$tM%1$tS
    // Enables the auto-save function after the backup.
    // Notice: If you set this to false, this plugin will backup your worlds but not save
    // the data from the memory to your hard disc. If the server crashes between
    // backups, all work is lost. Disable if you use another plugin to save the world
    // to disk (EG: autosave). (true/false)
    EnableAutoSave=true
    // Backup plugin directory? (true/false)
    BackupPluginDIR=true
    // Location of backups
    BackupDir=backups
    // Store all backuped world in one zip? (true/false)
    // If false every worlds backup is saved in one directory named in the format:
    // WORLDNAME_TIMESTAMP
    SummarizeBackupContent=true

    After this just type in your server
    /reload
    to reload the settings


    Permissions
    backup.canbackup

    Commands
    /backup starts a manuel Backup of your server. If you don't have permissions, everybody can run this command.
    /backup NAME starts a manuel Backup of your server. This backup is stored in backups/custom

    So far
    So Mel
     
  2. Offline

    EcoMaster21

    Backups are stored in the server root directory in a folder named backups.

    Would it be possible to implement a "quiet mode" for this plugin? I really do love this backup solution, but if I could cut down the chatter this plugin causes in the command line down to Backup Starting and Backup Complete, that would be oh so lovely.
     
  3. Offline

    Meldanor

    It is implemented in my development build by setting an empty line for the messages in the config.
    It uses the sheduler to create a own Thread for creating the backup. But it doesn't create a thread for copying and a thread to zip them.
     
  4. Offline

    ChazZTheSpazZ

    This is a great plugin! The backups take around 10-15 sec on my large world, but it's worth it. Today my first griefer logged in, proceeded to burn everything burnable, then told me he did so. He got banned, and the world was rolled back to a save 20 minutes before he logged in. Thanks for this!

    However, I would like to suggest a feature. Would it be possible for this plugin to save a backup automatically when a first-time user logs in? This isn't as relevant of a feature on my server where first-time users are not able to build until a Moderator approves, but I'm sure it would be quite useful on other servers that aren't set up like this.
     
  5. Offline

    halofreak506

    I've been wondering about the same thing, my server just recently went down because of the hard drive getting badly corrupted and the backups didn't do much help being stuck inside there.
     
  6. Offline

    Deadly_Paradox

    Could you please implement an option to change the color of the message this plug-in sends?

    EDIT: Is there a way to hide the ConsoleCommandSender messages it sends?

    Code:
    2011-05-06 18:23:16 [INFO] [Server] Backing up the world!
    2011-05-06 18:23:16 [INFO] Forcing save..
    2011-05-06 18:23:16 [INFO] ConsoleCommandSender: Forcing save..
    2011-05-06 18:23:16 [INFO] Saving chunks
    2011-05-06 18:23:16 [INFO] Save complete.
    2011-05-06 18:23:16 [INFO] ConsoleCommandSender: Save complete.
    2011-05-06 18:23:16 [INFO] Disabling level saving..
    2011-05-06 18:23:16 [INFO] ConsoleCommandSender: Disabling level saving..
    2011-05-06 18:23:18 [INFO] Enabling level saving..
    2011-05-06 18:23:18 [INFO] ConsoleCommandSender: Enabling level saving..
    2011-05-06 18:23:18 [INFO] [Server] Back up finished!
     
  7. Offline

    placeboing

    This is a nice plugin, thank you.

    I too am wondering both questions that Deadly_Paradox just asked.
     
  8. Offline

    Bjourk

  9. Offline

    desmin88

    @Meldanor
    With you 'fix' of using Asynchronous, instead of Synchronous, wouldn't your plugin now be non-threadsafe?
    You can't call any method from another thread other than main, exception of "getblocktypeidat()", without chances of data corruption etc.
     
  10. Offline

    Adam McFarland

    Any chance of a feature to customize the name of the save file?
     
  11. Offline

    xfxian

    As the project is being developed with NetBeans, the most accessible way is to install NetBeans and just open the project file. You will need to fix some imports (Permissions and CraftBukkit), to do that you just need to download those jar's and reference them in the IDE. Then it's just a click on the build button and you get your fresh snapshot.

    The other option would be to build it manually with javac, but that might be complicated if you're new to Java.

    Hope that helps.
     
  12. Offline

    Meldanor

    Another feature I will implement in my new version.

    Don't know what you mean.

    Yeah, there is a chance for an interaction between the threads, but my plugin works this like:
    The sheduler creates a thread and runs it every X minutes.
    The thread call the server to stop all savings to the hard disc by calling the server command "save-off". Before this, of course it saves all data from the memory to the hard disc.
    Then it copies all worlds to a temporary dir and zip them.
    I don't think there will be a data corruption, because I do not change any data, just make a copy.
    But you are right, when two backups are running at the same time, there can be a chance for data corruption, but then only the current backup may be corrupt and not the server.

    Implemented in development build.
    I don't know a way to disable this.
     
  13. Offline

    Galrath

    He means the mapping feature of that backup plugin. It was able to automatically render images via mcmap or c10t.
     
  14. Offline

    Meldanor

    No, i will not implement this feature, because this doesn't belong to an backup system. I want to concentrate on a backup plugin, not a general plugin for all basic functions.
    So, I'm sorry, but at this time I do not see a reason to implement this.
     
  15. Offline

    desmin88

    @Meldanor
    Actually, your calling the save method of world, not just making a copy.
    Therefore, it can cause world corruption on the current world.
     
  16. Offline

    fffizzz

    How bout an option for linux users to tar+gz the backups

    another possible feature would be FULL backup once per day and do incrementals throughout to reduce disk space.

    below is sample from script i was using, but i like the plugin better.. :)
    Code:
    BKUP_PATH=$MC_PATH/backup
    BKUP_DAYS_INCR=2
    BKUP_DAYS_FULL=2
    BACKUP_FULL_LINK=${BKUP_PATH}/${WORLD_NAME}_full.tgz
    BACKUP_INCR_LINK=${BKUP_PATH}/${WORLD_NAME}_incr.tgz
    
    		mkdir -p $BKUP_PATH
    		if [ -e $MC_PATH/$WORLD_NAME ]
    		then
    			if [ $ONLINE -eq 1 ]
    			then
    				echo "Server running, warning players : backup in 10s."
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "say Backing up the map in 10s\r"`"; sleep 10
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "say Now backing up the map...\r"`"
    				echo "Issuing save-all command, wait 5s..."
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "save-all\r"`"; sleep 10
    				echo "Issuing save-off command..."
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "save-off\r"`"; sleep 1
    			fi
    			cd $BKUP_PATH
    
                DATE=$(date +%Y-%m-%d-%Hh%M)
                FILENAME=$WORLD_NAME-$DATE
                BACKUP_FILES=$BKUP_PATH/list.$DATE
    
    			if test `date +%H` -eq 0 -o ! -f $BACKUP_FULL_LINK
                then
    				# Make full backup, and remove old incrementals
                    FILENAME=$FILENAME-full.tgz
    
                    # Remove incrementals older than $BKUP_DAYS_INCR
                    # Remove full archives older than $BKUP_DAYS_FULL
                    find ./$WORLD_NAME-*-incr.tgz -type f -mtime +$BKUP_DAYS_INCR -print > purgelist
                    find ./$WORLD_NAME-*-full.tgz -type f -mtime +$BKUP_DAYS_FULL -print >> purgelist
                    rm -f `cat purgelist`
                    rm -f purgelist
    
                    # Now make our full backup
                    pushd $MC_PATH
                    find $WORLD_NAME -type f -print > $BACKUP_FILES
                    tar -zcvf $BKUP_PATH/$FILENAME --files-from=$BACKUP_FILES
                    popd
    
                    rm -f $BACKUP_FULL_LINK $BACKUP_INCR_LINK
                    ln -s $FILENAME $BACKUP_FULL_LINK
                else
                    # Make incremental backup
                    FILENAME=$FILENAME-incr.tgz
    
                    pushd $MC_PATH
                    find $WORLD_NAME -newer $BACKUP_FULL_LINK -type f -print > $BACKUP_FILES
                    tar -zcvf $BKUP_PATH/$FILENAME --files-from=$BACKUP_FILES
                    popd
    
                    rm -f $BACKUP_INCR_LINK
                    ln -s $FILENAME $BACKUP_INCR_LINK
                	tar -zxvf $BACKUP_INCR_LINK -C /tmp
    	    fi
    
                rm -f $BACKUP_FILES
    			if [ $ONLINE -eq 1 ]
    			then
    				echo "Issuing save-on command..."
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "save-on\r"`"; sleep 1
    				screen -S $SCREEN_NAME -p 0 -X stuff "`printf "say Backup is done, have fun !\r"`"
    			fi
    			echo "Backup process is over."
    		else
    			echo "The world \"$WORLD_NAME\" does not exist.";
    		fi;;
    
     
  17. Offline

    THEK

    Hi,

    I'm still not getting automatic MultiWorld Backups. I still have to do it manually. All plugins are listed here.
     
  18. Offline

    Leemur

    make please an update..
    I want to backup my plugin file
     
  19. Offline

    Meldanor

    Hi guys,

    I'm having troubles to implement a better way for creating the ZIPs, so I can't say, when I can release it.
     
  20. getting an error every now and then.
    thought i'd paste it in here.

    Code:
    2011-05-10 18:46:31 [SEVERE] java.io.IOException: Write error
    2011-05-10 18:46:31 [SEVERE]     at java.io.RandomAccessFile.write(Native Method)
    2011-05-10 18:46:31 [SEVERE]     at java.io.RandomAccessFile.writeInt(Unknown Source)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.RegionFile.a(SourceFile:343)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.RegionFile.a(SourceFile:279)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.ChunkBuffer.close(SourceFile:259)
    2011-05-10 18:46:31 [SEVERE]     at java.util.zip.DeflaterOutputStream.close(Unknown Source)
    2011-05-10 18:46:31 [SEVERE]     at java.io.FilterOutputStream.close(Unknown Source)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.ChunkRegionLoader.a(SourceFile:64)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.ChunkProviderServer.saveChunk(ChunkProviderServer.java:160)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.ChunkProviderServer.saveChunks(ChunkProviderServer.java:190)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.World.save(World.java:148)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.World.doTick(World.java:1463)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:363)
    2011-05-10 18:46:31 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:287)
    
     
  21. Offline

    Oscarius

    Feature suggestion: Make us able to choose where to put the backups
     
  22. Offline

    desmin88

    @Meldanor
    You're ignorance towards the fact your calling MULTIPLE non-threadsafe methods in an Asynchronous schedule that can and will cause data corruption, sometimes unrecoverable has caused me to report your thread. I use to do this, and have since fixed the issue. You yourself should have done the same, however you ignored my warnings and others as well. Even if it may cause lag, it's a necessary evil.
     
  23. Offline

    fffizzz

    my users can deal with a minute of lag.. would rather be safe then have to deal with corruption..
     
  24. Offline

    EpicATrain

    I type /backup or /backup 05112011 and nothing happens. It just stares at me and does nothing. Help?
     
  25. Offline

    Meldanor

    I'm sorry for ignoring your hints. Thanks to your for giving me the hint, I'm working on a solution for this very fastly. I will run a kind of preparing thread running running sycronized on the sheduler doing all the "un-thread-safe" work. When this is done, this thread will create an asyncronized thread coping the worlds (and the plugin folder ;) ) and zipping them.

    Your config file has which content?

    We are now at version 1.5. Thanks for all your hints and reports. This update is very important because it prevent eventually data corruption. So to all users: Load the new update!
    • Added property to also backup the plugin folder(is set to true by default)
    • Fixed issue with data corruption by using not thread save methods. Thanks to desmin88 for the hints!
    • All worlds(and when enabled the plugin folder) is stored in ONE ZIP
    • Customize the timestamp by merge a fork of xfxian . Thanks to xfxian!
    • You can now disable enabling the autosave (the command "save-on", not the backup cyclus!) by setting the property to true. It is false by default. Notify, that I will run the command "save-off" before I will start the backup to prevent unwished results!
    • When server is starting, the config.ini is checked now. If you don't have the current config.ini you can see on the console a error. Remove / relocate the config temporary to get the newest one.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  26. Offline

    xGhOsTkiLLeRx

  27. Offline

    Meldanor

  28. Offline

    xGhOsTkiLLeRx

    Yes,

    one thing:

    Could you instead of a .rar make a .zip without the version number (in this case 1.5)?
    Because CraftBukkitUpToDate also supports .zip files. (Not sure about a .rar)

    Greetings
     
  29. Offline

    xZise

    Or tar.gz/bz2/xz :p then I could directly download it, because on the server I have no unzip :D

    Fabian
     
  30. Offline

    fffizzz

    sudo apt-get install unzip
    sudo yum install unzip
    :)

    I agree though that .rar is not a good option, straight link to .jar is preferred, but zip will suffice.
     
  31. Offline

    EpicATrain

    My problem was fixed. I didn't add myself to the admin permissions.
     

Share This Page