Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

Creating simple backups with WinRAR

2 min read

When I'm working on some code for a program I'm developing, I got into the habit of creating regular backups. That's quite useful, also when you're using a version control system (SVN, CVS,...). The backup can be very simple. Generally it is enough to zip the folder of your developing directory where your source-code and other project resources lie (i.e. Eclipse project workbench). It is however more handy if you automate the process. For this purpose I've written a !very! simple batch script in combination with WinRAR.
Lets take the following directory structure:
  • Projects
    • backups
      • MyProjectBackup
    • MyProject
    • ...
The folder structure is quite intuitive and actually reflects the one I'm accustomed to have. "Projects" is the root folder and can lie somewhere (i.e. D:\...\...\Projects\...). Inside the "Projects" folder, each project has its own directory such as "MyProject" in our example. Moreover in the "backups" folder there is another one where all the compressed rar-files (actually our backups) will be created.

The automated backup script is composed of two files: filelist.lst and backup.bat.
The filelist.lst contains the path(s) to the different locations which should be included in the backup. In our example it would look like this:

The 2nd file backup.bat contains the command line actions to the rar.exe file for creating the compressed backup. Its content looks as follows:

@echo off
"c:\Program Files\WinRar\rar.exe" a -agYYYY-MM-DD_HH.MM MyBackupFileName -r -m5 @filelist.lst

Here the highlighted path to the rar.exe has to be modified according to the right location on your own workstation. Both files (filelist.lst and backup.bat) should be placed inside the "MyProjectBackup" folder of our sample-folder structure. A simple double-click on the backup.bat creates the backup and puts it into the "MyProjectBackup" folder. For convenience purposes the backup.bat file can be linked from some other location (i.e. place a link to the desktop).
Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus