PerfectBackup
Backupping your server is one of the most important things to do as an owner. That's why I created the perfect tool for you, and for me.
This plugin is probably the easiest plugin to backup your server that exists!
Just by one command (/backup), you can save all your server (or just a part).
Then, with another command (/restore) you can restore an old backup!
With this plugin, you don't even need to launch craftbukkit to restore a backup!
You can launch the jar file with java like this:
“ java -jar PerfectBackup <backup_path> <server_path> [log] ”
With backup_path the path to your backup folder/zip,
server_path the path to your server's directory,
log a boolean (true/false) whether or not to show the debug log (default is true).
This will restore the backup of the folder/zip to your server, without even having to launch craftbukkit.
It can be used for Mini-Games where you want the server to reset automatically after each game.
You can also rename your backup files, and move them*. It will still work.
* If you move them, the in-game command /backups won't show them anymore.
This plugin adds three basic commands:
- /backup: Creates a backup of the server.
- /backups: Gives you a list of local backups.
- /restore [id]: Restores a backup.
- /delbackup [id]: Deletes a local backup.
/testftp: Tests the FTP connection.
# Config File # The automatic backup system. # Players with permission PerfectBackup.warning will be warned on automatic backup. # interval: 2 h # Interval format: # <amount> <t/s/m/h/d> # t = Ticks, s = Seconds, m = Minutes, h = Hours, d = Days crontask: '0 0 4 * * *' # This would make it every day at 4 AM # CronTask format: # * * * * * * # | | | | | | # | | | | | +–––– Day of the Week (1-7) # | | | | +–––––– Month (1-12) # | | | +–––––––– Day of the Month (1-31) # | | +–––––––––– Hour (0-23) # | +–––––––––––– Minute (0-59) # +–––––––––––––– Second (0-59) # A few more examples... # crontask: '0 0 * * * *' This would make it every hour # crontask: '0 0 4 * * 7' This would make it every sunday at 4 AM # crontask: '0 0 4 1 * *' This would make it every first of the month at 4 AM # The format for backup names. # If two backups have the same name, it will append " (1)", " (2)" etc. backupformat: 'PerfectBackup {DATE}' # The format for dates. # MM = month, DD = Day, YYYY = Year, HH = 12h Hours, hh = 24h Hours, mm = Minutes, ss = Seconds, ms = Milliseconds, AM = AM/PM dateformat: 'MM-DD-YYYY hhh mmm sss' # e.g. 03-10-2016 11h 47m 24s # Whether the backups should be in a zip file or in a folder. zipbackups: true # The folder where to store the backups locally. localpath: 'plugins/PerfectBackup/backups' # The maximum backups stored. Will delete older backups when reached. (≤ 0 to disable) # Note: this will only work with local backups (fallbacks included). maxbackups: -1 # Whether or not the plugin should broadcast when automatic backups start/end. # If this is set to false, only players with the PerfectBackup.warning permission will see it. broadcast: false # Whether or not the plugin should broadcast when manual backups start/end. # If this is set to false, only players with the PerfectBackup.warning permission will see it. manualbroadcast: true # Whether or not you should see detailed information while creating a backup. debug: false # Whether or not the server should be restarted when a backup is restored. # This will run the command line "cd dirname" and "java -server -jar jarfile" # dirname being the directory to the server and jarfile the first .JAR file found in the server directory restorerestart: true # FTP settings and configuration. # Different modes (when to use FTP): # - NEVER (disable) # - FALLBACK (when an error occurs) # - LIMIT (move files when maxbackups is reached) # - FIRST (use ftp unless an error occurs) # - ALWAYS (only save to ftp, never use local) # - BOTH (save to both ftp and local) ftp: mode: NEVER host: 'localhost' port: 21 user: 'PerfectUser' pass: 'P3rf3c7P455w0rd' path: '~/PerfectBackups/' # What you want in the backup. backup: jarfile: false # The .jar file of your server (e.g. craftbukkit.jar) properties: true # The server.properties file ops: true # The ops.json file whitelist: false # The whitelist.json file spigotyml: true # If on spigot, the spigot.yml file bukkityml: true # The bukkit.yml file aliases: false # The commands.yml file eula: false # The eula.txt file metrics: false # The PluginMetrics folder logs: false # The logs folder, with all the zips (WARNING! This can make your backups way slower and very heavy!) pluginjars: true # The .jar files for the plugins pluginconfs: true # The data folder of each plugin worlds: # Use [] for no world, and - '*' for all the worlds. - 'world' - 'world_nether' - 'world_the_end' other: # Any other file you want to backup, using "!" before will prevent it from backupping (IMPORTANT! Use / for directories!) - 'plugins/PluginMetrics' - '!plugins/Essentials' - '!plugins/WorldEdit' - '!plugins/PerfectBackup/backups'
In this config (it's the default one), we can see:
Interval
This is the time between each automatic backup.
It must have the format number + space + unit.
The available units are t (ticks), s (seconds), m (minutes), h (hours) and d (days).
If you put an invalid value (e.g. none, or leaving it empty), it will disable automatic backups.
Default is "2 h" (2 hours).
Cron Task
Here are the 6 cron task components:
1/ Second (0-59)
2/ Minute (0-59)
3/ Hour (0-23)
4/ Day of the Month (1-31)
5/ Month (1-12)
6/ Day of the Week (1-7)
Default is "0 0 4 * * *" (every day at 4 AM).
You could also use for example:
crontask: '0 0 * * * *' (This would make it every hour)
crontask: '0 0 4 * * 7' (This would make it every sunday at 4 AM)
crontask: '0 0 4 1 * *' (This would make it every first of the month at 4 AM)
Backup Format
This is the format of the backup names when they are saved.
If several backups have the same name, the second will have "_1" added, the third "_2", etc.
Use {DATE} to insert the date, with the format set in dateformat.
Default is "PerfectBackup {DATE}".
Date Format
This is the format of the date used for the backup format.
You can use for example:
24h: 'MM-DD-YYYY hhh mmm sss' (default)
AM/PM (12h): 'MM-DD-YYYY HHh mmm sss AM'
Zip Backups
If this is set to true, the backups will be stored in zip files.
If set to false or anything else, they will be saved in normal folders.
Default is true.
Local Path
The folder where to store the backups locally. Default is "plugins/PerfectBackup/backups".
Max Backups
The maximum number of backups stored locally.
Once it was reached, the oldest backups will be deleted.
Default is -1 (no limit).
Broadcast
ManualBroadcast
Debug
If this is set to true, detailed information will be shown while creating a backup (useful for debugging).
If not, only important information will be shown (start, errors, result).
Default is false.
Restart on Restore
If this is set to true, the server will restart when a backup is restored.
This makes it easier, so that you don't have to restart your server by hand.
WARNING! This might bug the console on some hosting services.
This is done with two commands:
- cd <dirname> (dirname is your server's directory)
- java -server -jar <jarfilepath> (jarfilepath is the path to the first JAR file found in your server's directory)
Default is true, but it isn't always recommended to have this on.
FTP
This is where you configure the FTP backup storing.
- Mode: When the FTP should be used (NEVER/FALLBACK/LIMIT/FIRST/ALWAYS/BOTH).
- Host: The host to access your FTP server.
- Port: The FTP server's port (default is 21).
- User: The user used to login on your FTP server.
- Pass: The password used to authenticate as the user above.
- Path: The directory where the backups will be stored on the server.
Backup
This is where you configure what will be backed-up or not.
- JAR File: Whether or not the JAR file of your server should be backed-up.
- Properties: Whether or not the server.properties file should be backed-up.
- OPs: Whether or not the ops.json file should be backed-up.
- Whitelist: Whether or not the whitelist.json file should be backed-up.
- Spigot YML: Whether or not the spigot.yml file should be backed-up.
- Bukkit YML: Whether or not the bukkit.yml file should be backed-up.
- Aliases: Whether or not the commands.yml file should be backed-up.
- EULA: Whether or not the eula.txt file should be backed-up.
- Metrics: Whether or not the Metrics folder should be backed-up.
- Logs: Whether or not the logs folder should be backed-up (WARNING! This can make your backups slower and very heavy!).
- Plugin JARs: Whether or not the plugins JAR files should be backed-up.
- Plugin Configurations: Whether or not the plugins data folder should be backed-up.
- Worlds: The worlds that will be backed-up, use [] for none, and - '*' for all the worlds.
- Other Files: Any other file you want to backup, using "!" before will prevent it from backupping. Use "/" to separate directories.
There are four permission nodes in this plugin, for the four commands:
- PerfectBackup.backup: Allows you to use /backup.
- PerfectBackup.list: Allows you to use /backups.
- PerfectBackup.restore: Allows you to use /restore.
PerfectBackup.testftp: Allows you to use /testftp.
TODO List
- Add a /testftp command to test the FTP connection.
- Add support for SFTP connexions and other remote protocols.
- Add remote backups to /backups, /restore and /delbackup commands.
- Add more cron format supports (at least ",", "-" and "/")
- Add a "dirtyonly" setting not to backup files that weren't changed since last backup.
- Add a command to restore completely a backup (deleting all the old files and restoring files only backed up in previous backups).
- Add a command to restore only some files such as maps or even regions inside maps.
If you want something added or changed, or if you have a question, tell me in the comments!
Known Bugs
If you find a bug, please open a ticket describing the problem so that I can fix it!
This plugin works quite simply, but it has some complex function.
For example, zipping and unzipping a file took me quite some time to understand.
I also had to make the plugin a runnable JAR file, so it can be run to restore backups.
Inside my code, I have five classes:
- The MetricsLite class, by Hidendra
- The main class, PerfectBackup, for all the commands, the config and the automatic backup.
- The CronRunnable API I have made, executing a runnable when a crontask is matched.
- The BackupRestorer class, with the main(String[] args) method ran when the JAR is launched.
- Last but not least, the BackupUtils class, handling everything else, including backup creation/restoring, date formatting, FTP and files: (un)zipping, copying/moving, deleting.
This is just an explanation for you to know exactly what's going on on your server.
I do not allow you to copy this plugin, or any part of it.
If you do modify it, you will have absolutely no support, and no guaranty.
Help me
If you like my plugins, share them, download them, and consider donating with the button at the top-right of this page.
Thank you for all the support you give me, and I hope my plugins will continue to help you.
I try to keep them a maximum up to date, but some times I don't have time to do that immediately, so it can be a bit delayed.
But don't forget to update them, and get the latest features on your servers!
Q & A
I don't have anything else to say here. But I think a Q&A would be appropriate, so there you go:
Q: Do you still work on updating this plugin ?
A: Unfortunately, no. Most of my public plugins aren't updated often as I don't have much time to spend because of my studies and my private projects.
But I do listen to ideas you propose and implement them as fast as possible (within a few hours for premium plugins).
Q: Is their any video so I can see how the plugin works ?
A: Yes, AbsintoJ has been kind enough to make a video.
Q: Does this work in 1.7 and 1.8 ?
A: It should, but since it is designed for 1.8, I didn't really test on 1.7.
Q: Why do I see [Metrics] in the console?
A: This is to get Statistics about my plugin, I use MetricsLite by Hidendra
Q: The auto restart on restore doesn't work, why?
A: This might be because of your hosting service, they could block the commands I use.
Or it might be because you have another JAR file that isn't your server JAR in the root of your server.
Q: Why "PerfectBackup"?
A: Because that's the perfect tool to help you create and restore backups, with just one command.
Off-topic Questions
Q: Why did you create this plugin? / What motivated you creating plugins?
A: I love creating stuff, and coding is my favorite activity, and since I love Minecraft too, I combined both and started making plugins.
For this plugin, yesterday, when I woke up, I felt I was bored. So I created that, and voila.
Q: How long do you take to code a plugin?
A: This one originally took me one day, but I maintain and work on them regularly.
Some can take me up to three or four days (and mini-games can be over a week).
Other questions?
If you have a question about this plugin or anything else:
- PM me, and I will add the Q + A here.
- Ask me in the comments below and I will respond.
- Open a ticket if it is a suggestion for this plugin or a bug report.
@Blackyvk You can backup to a MySQL server since v1.1 with the "ftp" section:
@Mr_Killer01 For now, PerfectBackup restores all the world so it doesn't support region backupping yet.
I might try to add this feature in the future but it will require an important amount of time that I don't have for now.
If you do want to restore per-region and without having to restart your server, you can add the schematics folder to backup in your custom file list in PerfectBackup's config and when you want to save your world, create a schematic (or override the last one) and use /backup.
You can then use /schematic load <name> to restore the world portion. To have an older version of your map, fetch it from the backups folder at the date you'd like and place the schematic in WorldEdit's appropriate folder.
That's a complicated work-around that can't be automated and is annoying to do, but it only uses WorldEdit and PerfectBackup.
If you search a bit on Bukkit/Google you will probably find a plugin that can restore regions easily such as http://dev.bukkit.org/bukkit-plugins/coreprotect/
But PerfectBackup works perfectly fine in 1.9, and has no bug for now. I keep updating it to fix things, improve performance and keep it up-to-date.
Thanks for testing PerfectBackup :)
I am puzzled by the variety of differences a backup should have or not have. I for instance, I like the idea that I can use snapshot in worldedit/worldguard (i'm always confused by who does what so bear with me on this) to just restore a selection of a world not having to kick every player from the server if i need to restore a little part of the world. I use now on 1.9 the plugin SimpleBackup, but it is having issues on this version of MC/Spigot, but i can't live without the safe idea that when something goes wrong i can depend on sbackup. The worst thing that happens now is that it triggers a shutdown of the server more often than once, and though i try to contact the maker of that plugin, i still am not succeeded in obtaining a newer, better and robuster version that matches the 1.9 rules... I hope you will be able to compete with SimpleBackup and implant this same option in your plugin, it makes restoring so much more easier....
Thanks for listening....
@au2001
good :), you think you can make mysql backups possible?
@Blackyvk For your worlds, remove them from the "worlds" section since they aren't in the server's root directory and add the "worlds" directory to the "other" section to backup the directory and it's sub-folders.
And yes, my plugin uses save-all to prevent corrupted worlds. That's why if you look closely in the console, you can sometimes see a message like "a manual (plugin-induced) world backup has been detected" during a backup ;)
my worlds arent inside the backup zip, is it because it's in a different folder like
worlds/world1
worlds/world2
worlds/world3
edit:
also, before backing up the world does the plugin execute save-all => save-off and then zips the world folder and after the zip is done then save-on? it should be like that to avoid files corruption.
@Penguinking4 Yes, this works in 1.9.
Does this work with Spigot 1.9? If not, when are you going to update it?
@Malvagio87 I am working on a "cron task"-like for automatic backups so you can put a time to start.
@charlza No, for now you can't backup all the worlds without specifying them manually... I will try to add a star "*" option to backup all the loaded worlds in the next update.
I've been using Minebackup successfully for years, but it was last updated for 1.6.4 and does not seem to work in my testing of 1.9. It's been orphaned for a long time.
I have a question about the worlds option in the config file in PerfectBackup. I interpret it to mean that you have to specify which worlds are backed up.
I routinely import and remove various worlds into my server via Multiverse. Is there a setting to simply backup every world that is currently in the server folder?
Thanks and looking forward to testing PerfectBackup!
Can you set a time when the backup will start?
@GodsDead
Unfortunately, the backup is created locally and then uploaded to FTP for practical reasons and for the fallback option.
If you need I can add a "DIRECT" option to backup only on the FTP server and sever on the SSD.
If you have another HDD disk installed on your machine you can make your backups go to there.
For your errors, I don't manage chunk myself only files to be sure not to corrupt any.
But it might be when saving the worlds. I perform a world save before each backup.
Could you post the full error log please?
It is probably Bukkit and not my plugin, but I can at still try to understand it and help you.
My servers quite large, and when I try to do a backup it fills up the SSD, so I cannot use this, the FTP always setting, does this make a backup locally first and then upload? or does it write directly to the FTP, this seems like it would solve my issue?
secondly, I had debug on, there was a ton of errors... Like "cant save chunk" errors. why is it trying to save a chunk? this should not touch my chunks.
@evolon13
I had the same problem at first. Turns out that the ' character would get changed to a ' (Yes theres a difference) whenever I edited the text file. Try copying this ' and replacing the old one before and after each world name.
Worked for me.
Awesome plugin! Simple commands and easy config.
Just one thing, I noticed when reading through the config that 'localpath' section defaults to 'plugin/PerfectBackup/backups' and creates a new folder called 'Plugin'. I changed it to 'plugins/PerfectBackup/backups'. I don't know if this was intentional, but the extra folder seemed kind of pointless. Not like it does any harm though.
Just wanted to let you know!
@au2001
How can I change the location of the backups? I have the server running on an SSD and would like to keep the writes as low as possible.
Amazingly helpful plugin!
Thanks for the awesome plugin! Using it on my multiverse server now.
I only have one problem: Somehow the worlds don't get saved when I list them all in the config. I currently have around 6-7 worlds on my server, can the plugin just include one of each kind (normal, nether, end)?
@au2001
Thanks for your fast answer. Im looking forward to the improvmence are going to make. The plugin is really helpful.
@lucasradon
You can use /perfectbackup:<command> to force the command to be executed by my plugin.
You can also disable the essential's command in the config :
If you need a custom alias, you can use the commands.yml file in the root of your server :
(this will execute /perfectbackup:backup when you type /perfectbackup ; "$1-" is to pass all the arguments, even if none are required for this command)
I am making a new system of automatic backup, allowing you to program it on a specified interval or at a specific time each day (I won't implement once a week, a month etc. yet).
And I'm also finishing the /delbackup command I told I would add in a previous post.
I really like your plugin,thanks for creating it,it helped me a lot! I've been using it for a longer time now and I have two ideas to improve it.
First of all,I need another command for "/backup". What I experienced is that your plugin and essentials are having a little conflict with each other and the command is interrupted by essentials. I think many servers,including mine,need both plugins so an alias command would be very helpful.
The second thing is that it would be nice if we could be able to tell a particular time when we want to create a backup. this means,that there would be an option like:"When do you want to make a backup?" - 3:45
It would be awsome :)
@Anemul
You can delete the backup manually without any risk. I will try to add a /delbackup to delete it on the FTP too (and wherever it has been saved)