endofzero / Minecraft-Sheller

Shell script designed to allow for automation of Minecraft Server Administration.
62 stars 18 forks source link

add (restore) <file> command to 'backup' #18

Open endofzero opened 13 years ago

endofzero commented 13 years ago

add (restore) command to 'backup'

add ability into the backup command to automate restoration of a backup file.

maybe start including a small hash to the filenames for easy picking, or just use full filenames.

A hard replace should really do the job in either incremental or full backups...

Incremental restores might be tricky though, could find a way to automate the iteration of in-between incremental if done that way. Pretty sure you would be required to restore incremental backups in order from newest to the time you are going for.

demonspork commented 13 years ago

actually, an incremental is only the differences from the last full backup, previous incrementals aren't even considered, so you just need to restore the full backup and the latest incremental.

demonspork commented 13 years ago
mv $MC_PATH/world $MC_PATH/world-replacedbybackup
cd $MC_PATH
tar -xvf $BACKUP_FULL_LINK
tar -xvf $BACKUP_INCR_LINK

and voila, you have a functional world from the latest backup. Needs some other stuff of course for handling as "minecraft.sh restore" but you get the idea. Also generating a list of possible incremental and full backup restore dates would be nice, so you can do "minecraft.sh restore list" and get a list of dates and times available for restoring and then use "minecraft.sh restore 2010-12-26-16h20" or even when you list out the possible backups you number them like this:

  1. 2010-12-26-16h20
  2. 2010-12-26-17h20
  3. 2010-12-26-18h20
  4. 2010-12-26-19h20
  5. 2010-12-26-20h20 and choose the backup with minecraft restore #3 or minecraft restore 2010-12-26-18h20

My bash skills are a little bit limited, but I will give this my best shot and see if I can get some or all of this done and you can use that, but if you are going to do it, please tell me so I don't waste time doing it like I did on the sync and lockfiles.

endofzero commented 13 years ago

:( sorry about the sync and lockfiles... when i get a programming idea in my head... I just kinda run with it...

You can take this on, if you want. I'd be glad to merge any pulls you come up with.

demonspork commented 13 years ago

I know what you mean, I sometimes forget to sleep when I am stupid enough to think all the way through to the end of a project. I am more familiar with Perl, C# and C++ though, I sometimes get stuck in Bash because of knowledge limitations.

Now to figure out how pull requests work.

demonspork commented 13 years ago

I don't know enough about manipulating strings in bash yet to make myself a list of backups so I am going to have to say that I can't do this yet. But I thought of a change to my original proposal that could be important:

cd $MC_PATH/backuprestore
tar -xvf $BACKUP_FULL_LINK
tar -xvf $BACKUP_INCR_LINK
mv $MC_PATH/$WORLD_NAME $MC_PATH/${WORLD_NAME}-replaced_by_backup
mv $MC_PATH/backuprestore/$WORLD_NAME $MC_PATH/$WORLD_NAME

this makes sure that no "sync" commands attempt to make a copy of a partially extracted world. It may even be better to add a lockfile to the sync command and use the lockfile for the sync command while running the restore command.

endofzero commented 13 years ago

I think we should keep it simple and keep with the lockfile check for that...

dopeghoti commented 13 years ago

I'm going to tackle proper locking for backups right now, followed by work on the restore functionality.

endofzero commented 13 years ago

yeah... not sure what my initial thoughts were... but it may be worth considering making it it's own function as opposed to it being tacked onto backup... so ./minecraft.sh restore 2010-01-05-02h32

or something... seems better to do it that way then something like: ./minecraft.sh backup restore 2010-01-05-02h32

, but either should do just fine. just figured i would throw that idea out there as separating it like that should allow for greater ease for improvement or adjustment without affecting the already-known-to-be-working backup function.

dopeghoti commented 13 years ago

Indeed, I was planning on making restore its own command.