Minecraft-Sheller icon indicating copy to clipboard operation
Minecraft-Sheller copied to clipboard

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

Open endofzero opened this issue 14 years ago • 9 comments

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.

endofzero avatar Dec 25 '10 09:12 endofzero

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 avatar Dec 26 '10 19:12 demonspork

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.

demonspork avatar Jan 02 '11 22:01 demonspork

:( 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.

endofzero avatar Jan 03 '11 00:01 endofzero

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 avatar Jan 03 '11 00:01 demonspork

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.

demonspork avatar Jan 03 '11 19:01 demonspork

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

endofzero avatar Jan 05 '11 00:01 endofzero

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

dopeghoti avatar Jan 06 '11 03:01 dopeghoti

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.

endofzero avatar Jan 06 '11 04:01 endofzero

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

dopeghoti avatar Jan 06 '11 07:01 dopeghoti