I dunno if anyone even uses Eclipse, but I'm pretty sure this is applicable to any make-file using environment.

My friend (with a little help from me) made a C executable that uses winrar to automatically backup files on make, or by a special make using the backup option.

I've included the exe file, and I'll also post the code. It creates backups in the form:


YYYY = 4 digit year (2003)
MM - 2 digit month (01 - 12)
DD = day (01 to 31)
hh = hour (00 to 23)
mm = minutes (00 to 59)

It backs up all files in the directory, minus any other .rar files. This can easily be changed one of two ways...by adding more -x*.xxx files to exclude, or by adding a bunch of *.xxx files to include. (see winrar help for more info)

I found it very handy...thought I'd share.

You can also add the command to your makefile, by adding (under all: or by adding a backup: section) backup.exe

Feedback would be appreciated!


#include "iostream"
#include "time.h"
#include "string.h"
#include <stdlib.h>

using namespace std;

int main(void)
    char tmpbuf[30];
    time_t ltime;
    struct tm *today;
	char cmdline[128] = "rar a -r -x*.rar ";

    /* Use time structure to build a customized time string. */
	time( &ltime );
    today = localtime( &ltime );

    /* Use strftime to build a customized time string. */
    strftime( tmpbuf, 128,
         "Backup-%Y%m%d-%H%M.rar", today );

	cout << "Backing up files now!\n";
	cout << "Writing file: ";
	cout << tmpbuf;
	strcat( cmdline, tmpbuf);
	strcat( cmdline, "\"");
	return 0;