Automated Database Backup
With the help of the Windows Task Scheduler, you can easily setup an automated backup schedule for your Acronis Cyber Files database.
Creating the database backup script
- Open Notepad (or another text editor) and enter the following:
@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
echo datestr is %datestr%
set BACKUP_FILE=AAS_%datestr%_DB_Backup.sql
echo backup file name is %BACKUP_FILE%
SET PGPASSWORD=password
echo on
bin\pg_dumpall -U postgres -f %BACKUP_FILE%
move "%BACKUP_FILE%" "C:\destination folder"
- Replace "password" with the password for user postgres you have entered when you installed Acronis Cyber Files.
- Replace C:\destination folder with the path to the folder where you want to save your backups.
- Save the file as DatabaseBackup.bat (the extension is important!) and select All Files for the file type.
- Move the file to the PostgreSQL installation folder in the version number directory (e.g. \9.3\).
Creating the scheduled task
- Open the Control Panel and open Administrative Tools.
- Open the Task Scheduler.
- Click on Action and select Create Task.
On the General tab:
- Enter a name and description for the task (e.g. AAS Database Backup).
- Select Run whether user is logged in or not.
On the Triggers tab:
- Click New.
- Select On a schedule for Begin the task.
- Select daily and select the time when the script will be run and how often the script should be rerun (how often you want to backup your database).
- Select Enabled from the Advanced settings and press OK.
On the Actions tab:
- Click New.
- Select Start a program for Action.
- For Program/Script press Browse, navigate to and select the DatabaseBackup.bat file.
- For Start in (optional), enter the path to the folder in which the script resides. e.g. If the path to the script is
C:\Program Files (x86)\Acronis\Files Advanced\Common\PostgreSQL\9.3\PSQL.batenterC:\Program Files (x86)\Acronis\Files Advanced\Common\PostgreSQL\9.3\ - Click OK.
- Configure any additional settings on the other tabs and press OK.
- You will be prompted for the credentials for the current account.