Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dwarfort.bat: an unlimited save backup utility  (Read 753 times)

Savok

  • Bay Watcher
    • View Profile
Dwarfort.bat: an unlimited save backup utility
« on: October 01, 2007, 09:24:00 pm »

I decided to try making a save backup .bat file.
I placed a fairly poor utility in this thread. It could only make a finite number of saves, and a fairly low number, since it had to move a folder (contents=~12mb) once per save.
Nilas Hadean gave me a code that would result in unique save names. It had a couple errors, but both minor.
Here is that code, made into a working .bat file:
code:
dwarfort.exe
cd data
set DATE_SHORT=%DATE:~4%
set DATE_FRIENDLY=%DATE_SHORT:/=-%
set TIME_SHORT=%TIME:~0,8%
set TIME_FRIENDLY=%TIME_SHORT::=.%
set BACKUP_NAME=%DATE_FRIENDLY%,%TIME_FRIENDLY%
xcopy save savearchive\%BACKUP_NAME% /e /v /t /q


(just paste into Notepad, save as a .txt file, change the extension to .bat, and place it in the same folder as dwarfort.exe)

It runs DF, and when you quit DF, it backs up the save folder. The name of the folder is the date and time at which it backs up the folder.

The only problem is that you may have to press "d" at the end of the process to get it to finish. I haven't figured out how to suppress that prompt.

[ October 05, 2007: Message edited by: Savok ]

Logged
So sayeth the Wiki Loremaster!

FFLaguna

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #1 on: October 01, 2007, 10:27:00 pm »

WOW! I logged in just to say 'thank you'! So, thank you!
Logged

Tahin

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #2 on: October 01, 2007, 10:33:00 pm »

Sounds awesome... Anyone know how to make Wine run .bat's, or am I screwed?

[ October 01, 2007: Message edited by: Tahin ]

Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #3 on: October 01, 2007, 11:23:00 pm »

Google says "wcmd" or "wineconsole"

No idea how to do it with batch files, or if it's even possible, but it'd be fairly simple to whip up a full program which does that, and even read a config file to limit the number of backups. If you're interested I could do it in Freebasic tomorrow.

Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

huhu

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #4 on: October 02, 2007, 02:19:00 am »

You don't need .bat files when using wine. Bash has a much more comprehensive scripting language to it - Look for "bash scripting" in Google.
Logged

Tamren

  • Bay Watcher
  • Two dreams away
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #5 on: October 02, 2007, 04:03:00 pm »

nice work

this will probably work on the new version right? assuming none of the save mechanics change.

Logged
Fear not the insane man. For who are you to say he does not percieve the true reality?

Lightning4

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #6 on: October 02, 2007, 04:04:00 pm »

Probably, but it won't be necessary. Next version will have a save backup feature in addition to autosave.

[ October 02, 2007: Message edited by: Lightning4 ]

Logged

Nilas Hadean

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #7 on: October 02, 2007, 04:17:00 pm »

Ah... I created a PowerShell script to back up saves about a year ago.
http://rafb.net/p/3eLZEg58.html

Not that it will help much, what with the new version coming out soon :-).

The commands basically run down as:
df <action>
Actions:
- Start : Loads DF.
- Archive : Copies the current regions to a unique backup location.
- Remove <name> : Removes the chosen backup instance.
- Revert <name> : Replaces the current DF save with the selected one.
- Saves : Lists known backup instances.

---

If I had to do it over again, I'd simply forgo the effort and use Darcs/Git or some other version control system.

[ October 02, 2007: Message edited by: Nilas Hadean ]

Logged

Nilas Hadean

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #8 on: October 02, 2007, 04:39:00 pm »

Oh, and to get unique save names for a batch script you could try something like the following:

code:

SETLOCAL ENABLEEXTENSIONS

SET DATE_SHORT=%DATE:~4%
SET DATE_FRIENDLY=%DATE_SHORT:/=-%

SET TIME_SHORT=%TIME:~0,5%
SET TIME_FRIENDLY=%TIME_SHORT::=.%


SET BACKUP_NAME=%DATE_FRIENDLY% %TIME_FRIENDLY%
echo %BACKUP_NAME%


Logged

Savok

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #9 on: October 02, 2007, 06:26:00 pm »

I know next to nothing about DOS; how would I implement that?

EDIT: Thanks for the PM explaining how to.

[ October 05, 2007: Message edited by: Savok ]

Logged
So sayeth the Wiki Loremaster!

Savok

  • Bay Watcher
    • View Profile
Re: Dwarfort.bat: an unlimited save backup utility
« Reply #10 on: October 05, 2007, 03:01:00 pm »

*bumps thread due to major update in first post*
Logged
So sayeth the Wiki Loremaster!