Backup to encrypted 7zip file

Chris Good chris.good at ozemail.com.au
Sat Sep 13 22:22:24 EDT 2014


Hi GnuCash users,

 

Here's a batch file I hope some Windows users may find useful.

 

I back up my GnuCash files to Dropbox, but just in case, I'm not happy
putting my unencrypted data in the cloud, so I cannot just save my GnuCash
data file to the Dropbox folder.

 

This script creates an AES-256 encrypted 7zip file in my Dropbox folder.

It contains my GnuCash data file (xxx.gnucash),

my saved custom report configuration file (saved-reports-2.4),

and the settings file (xxx.gcm).

 

You can install  7zip (free) from http://www.7-zip.org/

 

Each time after I finish entering data into GnuCash (&after GnuCash is
closed), I just run the batch file (double click on the new icon on the
desktop), enter the password I want to encrypt with, and check for any error
messages. The encrypted file is added to the Dropbox folder, which is just a
folder on my PC, and within seconds, Dropbox has copied it to the cloud.

 

You could probably use this with other cloud storage services also, or just
for backing up GnuCash to your PC if you don't use a cloud storage service.

 

The encrypted 7zip file has a name like GnuCashMyDataFile_yyyymmdd_hhmm.7z

where MyDataFile is the name of your GnuCash data file and

yyyymmdd_hhmm is the year,month,day, hour,min.

 

Note: If you run it twice within the same minute, the 2nd encrypted file
will overwrite the first as they have the same name.

 

This script is provided free in the hope it will be useful, but I accept no
responsibility for any problems and there is no warranty!

Please test to ensure it works for you!

 

I'm using Windows 7 and GnuCash 2.6.2 but I believe this script should work
for at least Windows XP, 7 & 8, and GnuCash 2.4.x thru 2.6.3.



To install:

 

Right click on the Windows desktop, New, Text Document. 

Rename the New Text Document.txt on your desktop to, say, BackupGnuCash.bat

(Be careful with the extension if you have the default option 'Hide
extensions for known file types' ticked.  - it must be .bat, NOT .txt.

You can change this option in Windows Explorer: Organise, Folder & search
options, View tab, Advanced settings)

 

Right click on BackupGnuCash.bat, Edit, and it should open the empty
document in Notepad.

Copy the following script into the Notepad window.

Edit all the lines after lines with 'Following' on them to customise for
your particular folders and GnuCash data file name.

Save the file (Control-S), close Notepad

 

############ batch file follows- do not include this line
########################

 

@echo off

echo.

echo Backup GnuCash to 7zip AES-256 encrypted file in DropBox

echo.

 

rem 14/09/2014 CRG Created for any GnuCash user.

 

rem Following is GnuCash data file drive

set GcDrive="C:"

 

rem Following is GnuCash data file folder

set GcDir="\Users\cgood\GnuCash"

 

rem Following is GnuCash data file WITHOUT .gnucash suffix

set GcFile="MyDataFile"

 

rem Following is location of 7z.exe

set zip="C:\Program Files\7-Zip\7z.exe"

 

set /p pswd="Enter password: "

 

rem Following is output 7zip folder - I use a GnuCash sub folder within
Dropbox

rem If you use a sub folder, you should create it before running this batch
file

set ZipDir="C:\Users\cgood\My Documents\Dropbox\GnuCash"

 

set yyyymmdd_hhmm=%date:~6,4%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%

 

rem Following is output AES-256 encrypted 7zip file

set ZipFile="GnuCash%GcFile%_%yyyymmdd_hhmm%.7z"

 

cd /D "%GcDrive%%GcDir%"

 

rem Note: USERPROFILE should be set by default to C:\Users\%USERNAME%
It is on Windows 7!

 

echo on

 

%zip% a "%ZipDir%\%ZipFile%" -p"%pswd%" "%GcFile%.gnucash" ^

%USERPROFILE%\.gnucash\saved-reports-2.4 ^

%USERPROFILE%\.gnucash\books\%GcFile%.gnucash.gcm

 

Pause

 

### Pause above is last line in batch file ######################

 

I have also created a JavaFX Windows app for doing the same thing, (but it
looks much nicer J).

As it uses JavaFX, it needs Sun Java RTE 1.8 which could perhaps be too new
for some other Java apps, but it works fine for me.

Is anybody interested in that? If there are many people interested, I can
put the source and .jar on git, I guess, or if they are only a few, I can
email directly. I'll need to modify it first to remove some customisations
which are specific to me.

 

I could also create a Linux shell script to do the same thing as this
Windows batch file if anyone is interested?

 

Regards,

 

Chris Good

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6091 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20140914/d709ce63/attachment.p7s>


More information about the gnucash-user mailing list