PerfectBackup

Banner Description 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.

Commands 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.

Configuration

# 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.

Permissions 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 & Bugs

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!

How it works 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:

  1. The MetricsLite class, by Hidendra
  2. The main class, PerfectBackup, for all the commands, the config and the automatic backup.
  3. The CronRunnable API I have made, executing a runnable when a crontask is matched.
  4. The BackupRestorer class, with the main(String[] args) method ran when the JAR is launched.
  5. 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.

More details

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:

  1. PM me, and I will add the Q + A here.
  2. Ask me in the comments below and I will respond.
  3. Open a ticket if it is a suggestion for this plugin or a bug report.

Statistics Global statistics


Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    91394
  • Created
    Apr 24, 2015
  • Last Released File
    Nov 17, 2016
  • Total Downloads
    23,096
  • License

Categories

Members

Recent Files