Knowledgebase Support HMRC Useful links
Knowledgebase home
Tax Return Production
Accounts Production
Practice Management
VAT Filer
CloudConnect
Anti-Money Laundering
Support home
Video Training Guides
NEW

Hot Topics
SimpleStep Guides
Release Notes
Technical
Known Issues

HMRC Status
Useful Links
MTD for Agents MTD for Businesses What is MTD
Preparation
Agent Services Account
MTD for VAT
MTD for Income Tax
MTD for VAT
Digital Record Keeping
Quarterly Updates
Step-by-step Guide
HMRC's MTD Timeline
TaxCalc's MTD Journey

Automatic backup of TaxCalc on a server

Article ID: 2054
Last updated: 27 Dec, 2019

The network version of TaxCalc uses the Postgres database engine. Backups need to be made on the server itself - there is no capability for users to make an automatic backup of the database from a 'client' computer.

In a full blown server environment it may not be possible or desirable for users to have access to the server in order to make a backup of the database. In such cases, an automatic backup process is desirable.

The following information will help a system admin create a process that allows you to make an automatic backup of the TaxCalc database.

PLEASE NOTE: This needs to be run from the server where Postgres is installed. You will need to know the root database password (set when TaxCalc was configured).

Changes will need to be made to the file to suit your own environment. This example backs up to a folder called z:\share\taxcalcbackups. The .bat file is called tcbackups.bat and is stored in the z:\share folder. Modify this for your own environment. TaxCalc takes no responsibility for a failure to take adequate backups of your own data.

IMPORTANT: This article assumes the port used is 5432. If the installation is more than two years old you may be using Port 5433. If your backup fails, use PGAdmin to determine the correct port in use.

The first thing to do is create a batch file and add the following commands to it:

 set PGPASSWORD=Your_root_database_password
c:
cd\
cd "Program Files\PostgreSQL\9.4\bin"
pg_dump.exe -Fc -f "Z:\share\Taxcalcbackups\taxcalchub_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%.backup" -U postgres -p 5432 -h localhost hub
FORFILES /p z:\share\taxcalcbackups /d -21 /m * /c "cmd /c del @file"

For 64 bit servers it looks slightly different:

 set PGPASSWORD=Your_root_database_password
c:
cd\
cd "Program Files (x86)\PostgreSQL\9.4\bin"
pg_dump.exe -Fc -f "Z:\share\Taxcalcbackups\taxcalchub_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%.backup" -U postgres -p 5432 -h localhost hub
FORFILES /p z:\share\taxcalcbackups /d -21 /m * /c "cmd /c del @file"

Note: This batch file uses the forfiles command.

Explanation of the batch file

Setting the environment variable:

set PGPASSWORD=Your_root_database_password

Change to the Postgres install directory (so that the command can run):

cd\ cd "Program Files\PostgreSQL\9.4\bin"

or

Change to the Postgres install directory (64 bit server):

cd\ cd "Program Files (x86)\PostgreSQL\9.4\bin"

The next line runs the back up command, appending the date and time to the name and putting it in the correct folder (in this example the destination folder is specified as z:\share\taxcalcbackups):

pg_dump.exe -Fc -f "z:\share\taxcalcbackups\taxcalchub_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%.backup" -U postgres -p 5432 -h localhost hub

The last job is to remove all files in the directory older than x days (in this example it is 21 days):

FORFILES /p z:\share\taxcalcbackups /d -21 /m * /c "cmd /c del @file"

Once the .bat file is created, save it to a directory and test that it works. You can then add it to the task scheduler to make it run at regular intervals.

How to add a .bat file to Task Scheduler

Open a command prompt as administrator and type the following command (changing it where necessary to set the correct paths and user credentials):

SchTasks /Create /SC DAILY /TN “Backuptaxcalc” /TR c:\share\tcbackups.bat /ST 13:00 /RL HIGHEST /RU username /RP password

This will create a scheduled task called 'backuptaxcalc', to run every day at 13:00, which will run the tcbackups.bat file. It will run whether the user is logged in or not (as long as the machine is turned on).

Remember: If you change the user password, change the scheduled task as well. You may want to create a specific account under which this can be run. It is your responsibility to ensure the scheduled task is running.

TaxCalc can take no responsibility for automatic backups that do not run

Article ID: 2054
Last updated: 27 Dec, 2019
Revision: 41
Views: 3927
This article was:  


Also listed in
folder Technical -> Backing up and Restoring
folder Technical -> Database Related