by date
Simple backup script
Simple backup script
| Name: | Johnathon | |
|---|---|---|
| Date Posted: | Nov 11, 2007 | |
| Rating: | Not Rated | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Johnathon |
Blog post
I wrote a simple little windows batch file that would backup my project to my server, however you can use it to copy it to your local hard-drive as well.
and if you want it to backup on your local hardrive
I then use my Windows Scheduler to schedule a backup everynight.
This is where you connect to your server that you want to backup your data to. If you are backing up to your local hard drive you won't need to use this command. /PERSISTANT means that the network connection will not re-connect when you reboot your computer. It connects this one time only.
This deletes all of the compiled .dso files in your project prior to backing up your project. You can remove this if you want to back those up as well, but it will decrease the backup time by deleting the dso's first. Less files to copy.
next we check if the backup directory already exists. The %date:~0,3% returns the date, trimmed down to just three characters. if you execute this on Sunday, then your directory would be named MyGame\Sun.
if Backups\Torque\myGame\Sun exists, it deletes the directory. /S deletes all the sub folders and files, /Q puts it in quiet mode. If you don't use the /Q then you will be required to enter Y at the command promt to give the RD command permission to delete all files.
xcopy copies all the files and folders in your MyGame into your backup folder with the name of the date. the /y suppresses the promt to overwrite files, which we really shouldn't have that problem anyway because we are deleting the directory if it exists. /S copies all the subfolders and files.
If you are copying to your local harddrive you won't need this command. This will disconnect you from your server once the script has completed.
net use b: \\domainName\UserName passwordHere /PERSISTENT:no
del /s *.dso
IF EXIST B:\Backups\Torque\MyGame\%date:~0,3% RD B:\Backups\Torque\MyGame\%date:~0,3% /S /Q
xcopy C:\Torque\MyGame\* "B:\Backups\Torque\MyGame\%date:~0,3%\*" /y /s
net use b: /DELETE
and if you want it to backup on your local hardrive
del /s *.dso
IF EXIST C:\Backups\Torque\MyGame\%date:~0,3% RD C:\Backups\Torque\MyGame\%date:~0,3% /S /Q
xcopy C:\Torque\MyGame\* "C:\Backups\Torque\MyGame\%date:~0,3%\*" /y /s
I then use my Windows Scheduler to schedule a backup everynight.
net use b: \\domainname\username passwordhere /PERSISTANT:no
This is where you connect to your server that you want to backup your data to. If you are backing up to your local hard drive you won't need to use this command. /PERSISTANT means that the network connection will not re-connect when you reboot your computer. It connects this one time only.
del /s *.dso
This deletes all of the compiled .dso files in your project prior to backing up your project. You can remove this if you want to back those up as well, but it will decrease the backup time by deleting the dso's first. Less files to copy.
IF EXIST B:\Backups\Torque\MyGame\%date:~0,3% RD B:\Backups\Torque\MyGame\%date:~0,3% /S /Q
next we check if the backup directory already exists. The %date:~0,3% returns the date, trimmed down to just three characters. if you execute this on Sunday, then your directory would be named MyGame\Sun.
if Backups\Torque\myGame\Sun exists, it deletes the directory. /S deletes all the sub folders and files, /Q puts it in quiet mode. If you don't use the /Q then you will be required to enter Y at the command promt to give the RD command permission to delete all files.
xcopy C:\Torque\MyGame\* "C:\Backups\Torque\MyGame\%date:~0,3%\*" /y /s
xcopy copies all the files and folders in your MyGame into your backup folder with the name of the date. the /y suppresses the promt to overwrite files, which we really shouldn't have that problem anyway because we are deleting the directory if it exists. /S copies all the subfolders and files.
net use b: /DELETE
If you are copying to your local harddrive you won't need this command. This will disconnect you from your server once the script has completed.
Recent Blog Posts
| List: | 01/07/08 - Airhead Gaming goes live 12/08/07 - Airhead Gaming 11/29/07 - Solitaire *Work in progress* 11/18/07 - New direction 11/16/07 - Mission Load Stage 2 endless loop 11/11/07 - Simple backup script 11/08/07 - Creating a canvas 11/08/07 - A Basic console |
|---|
Submit your own resources!| Andy Hawkins (Nov 11, 2007 at 23:01 GMT) |
| Shawn Simas (Nov 12, 2007 at 00:02 GMT) |
| Novack (Nov 12, 2007 at 02:36 GMT) |
| Johnathon (Nov 12, 2007 at 04:23 GMT) |
Shawn is correct, the
del /s *.dso
just deletes all of the compiled torque scripts in your working project directory. It is up to you, you can not add this line if you want.
and the
net use b: /DELETE
just deletes the network connection to your server if you are connecting to a server. If you are not connecting to a server and backing up your project, just omit both "net use" commands.
To help make you feel better, make a manual backup of your project and store it someplace until you have your script working the way you want it to.
Edited on Nov 12, 2007 04:24 GMT
| Tom Bampton (Nov 12, 2007 at 05:13 GMT) |
Edit: Or any other SCM system ... ;-)
Edited on Nov 12, 2007 05:14 GMT
| Johnathon (Nov 12, 2007 at 06:12 GMT) |
I tried looking for an all in one solution, but couldn't find anything. I'm open for suggestions!
| Gary Preston (Nov 12, 2007 at 11:44 GMT) |
[general]
password-db = passwd
realm = PickAName
anon-access = none
anon-read = none
auth-access = write
Then setup a passwd file
[users]
gary = mypasswordhere
For additional info svnbook.red-bean.com/. I find having SVN access even for projects where it's just me, is highly useful. Aside from the check-in to a remote machine acting as a first backup, you never know when you might want to allow someone else access to your repo.
| Andy Hawkins (Nov 12, 2007 at 11:56 GMT) |
We lost 3 days at work last week because the branch we were working on got mangled merging from the trunk. We will never work on a branch again...
Edited on Nov 12, 2007 11:56 GMT
| Steve Flowers (Nov 12, 2007 at 12:47 GMT) |
I agree with Andy, SVN sucks. But sometimes... SVN unsucks itself -- when it saves your ass or enables your team to collaborate on a project, see what was done when, and revert to any version of any file. NTM the integration with TRAC, which in my experience is one of the greatest things about SVN:)
I'm hoping to see SVN be a little more flexible / graceful in the future. Things can get ugly if a user (or in rare cases, SVN itself) gets squirrely.
| Andy Hawkins (Nov 12, 2007 at 13:00 GMT) |
I just can't trust it. But I do like team collaboration on such things - I occasionally branch out and employ a few people which is when it would count... hey this is a bit off topic - sorry Johnathon.
| Michael Perry (Nov 12, 2007 at 14:46 GMT) |
In the spirit of this blog, I posted a follow-up to my Source Control How-To resource with a nightly build/backup system using Windows, batch files, and Subversion. It is similar to this blog, except it incorporates Subversion to do a checkout as well.
@Johnathon - I take it you found errors following the my resource? No one else claimed to have run across any Apache errors, so I'm interested in what you might have run into. If you e-mail me, I'll help you out one on one with the error, as I think keeping your projects under source control is a good idea (especially with what you are doing).
| Jeff Leigh (Jeffer) (Nov 12, 2007 at 18:33 GMT) |
> Subversion
> Tortoise SVN (makes using SVN a breeze from Windows Explorer right click context menus)
> WinMerge (alleviates all merging/branching issues)
I use branches and multiple repositories extensively and have never (knock on electrons) had a problem with SVN corruption.
Here's the key:
DO IT YOURSELF - don't allow SVN to merge branches for you and you won't have any troubles. SVN does an adequate job of this, way better than CVS ever did, but for complicated projects - just don't trust it. And there's no need to because WinMerge makes it easy to do it yourself.
1. Check out a working folder of your trunk
2. Check out a working folder of your branch
3. Do a compare between the two with WinMerge
4. Merge the branch into the trunk
5. Commit the trunk
I do this everyday as a matter of routine and have never had a branch corrupt a trunk.
If you're having install problems for subversion check out VisualSVN Server for a brainless install. It installs its own copy of Apache on port 81, setts up the repo folder for you and gives you a real easy to use security UI (which can be the biggest pain for new SVN users).
Edited: Fixed bad link.
Edited on Nov 12, 2007 18:48 GMT
| Tom Bampton (Nov 12, 2007 at 18:58 GMT) |
A well run repo will save you a lot of time, hassle and premature hair loss. Backing up by hand, even with the use of batch files, is error prone, time consuming and seriously wasteful of HD space. That said, at the end of the day, everyone has their own preferences. Personally, it is completely incomprehensible why anyone would not want to use SCM :)
For those having problems with merging, what Jeff Leigh suggests above is really good advice. Beyond Compare is better than WinMerge though ;-) Other than bugs in early versions of svn, and a couple of cases of stupid user syndrome, I've havent had any problems with svn either.
It's also worth pointing out that Subversion is not the only SCM solution. Perforce is a good commercial one; though prohibitively expensive for indie teams, there's a free version that would likely suit a one man "team" quite well. I'd suggest poking around the net and trying some out. Whatever you do though, stay away from Visual SourceUnsafe ... it has that universally recognised nickname for a reason :)
T.
| bank (Nov 12, 2007 at 22:39 GMT) |
SCM is a MUST for a developer. What to use - it's like "what you prefer: Opera, FireFox or IE". Find the one that you can feel "safe" with.
First, I started with "classic" CVS.. Later moved into SVN. Set up a separate server just for SVN. At first - I used separate repo-s when making "branches"... While I grow at understanding on "how all of this works" I found this really useful for myself. A good planned project can live a long life on SVN (assuming you have a failover-backup like on tapes or external HDD).
For now (as of today) I can't even imagine to work without SVN. Even all of my "notes" (.TXT files) are SVN-ed :)
@Johnathon: you can add to your instructions the /H parameter, it will tell the xcopy to include ALL files (including marked as hidden/system). And the /G can be useful too (Allows the copying of encrypted files to destination that does not support encryption)
:)
| Andy Hawkins (Nov 13, 2007 at 00:06 GMT) |
| Johnathon (Nov 13, 2007 at 01:48 GMT) |
@Gary Preston:
I will try svnserv if I can't get apache up and running.
@Andy Hawkins
No problem :D
@Michael Perry
yes, it was your resource I was following when I tried to setup my subversion, I think the problem was not in your resource, but in the fact that I couldn't find the same version's of Apache and subversion that you where using.
Your Version->My Version
Apache 2.0.59->2.2.6
Subversion 1.3.2->1.4.5
I don't remember exactly what the error was, something about not being able to use an ip of 0.0.0.0:80, but I will re-install apache and see what the error actually says and fire you an email. Thanks for the help!
@Jeff Leigh
I will look into that as well if I can't get Michael's resource to work.
@bank:
From what I've read it sounds like SCM really helps out with the project management. Thanks for the tip on the /H and /G parameters. I'll be using my script until I can get subversion working.
| bank (Nov 13, 2007 at 02:20 GMT) |
you should be able to just create a new "repo" by TotroiseSVN without using any apache/subversion (on Windows).
Install TotroiseSVN, reboot if needed. Create a folder (e.g. C:\repo\), right click on it and choose from menu "TotroiseSVN" and then "Create repository here..." submenu option... then... do what you want.
I would recommend you to start playing with TotroiseSVN first, create a few empty repo's, do import/checkout/etc. And, btw, you can have this folder on network-shared drive and can access from multiple computers.
This is "aSap" (as Simple as possible) case of getting "in touch" with SVN basics (windows-friendly behaviour). And yeah, there are a lot of different manuals and HOWTO's on internet about SVN.
The TotroiseSVN is just about "visualization" - it can really help you to start with SVN itself. What you will use at the end - is up to you. Read what others said up on the thread here (incl. Andy's comment about Tortoise being not so good sometimes).
| Johnathon (Nov 13, 2007 at 02:38 GMT) |
Thanks, I'll spend tonight messing with totroiseSVN, I have it installed just haven't used it. I noted what Andy said about it not being to good with branching, I will keep this in mind. I would assume as long as you know what you are doing it, and do it manually instead of allowing SVn to automate the trunks, you would be ok?
| Jeff Leigh (Jeffer) (Nov 13, 2007 at 02:40 GMT) |
Your Version->My Version
Apache 2.0.59->2.2.6
Subversion 1.3.2->1.4.5
Stay away from Apache 2.2.x unless you know what you're doing with Apache. It's too new and there are issues (peculiarities) with SVN 1.4.5 - they're both too new and untested in my opinion.
Edited on Nov 13, 2007 02:41 GMT
| Johnathon (Nov 13, 2007 at 23:56 GMT) |
Thanks, Michael worked with me last night and we got it setup and running on my machine with the 2.0.59 version of Apache. W00t! I feel like I just pimped my computer.
You must be a member and be logged in to either append comments or rate this resource.


Not Rated


