S3 Gateway: Back Up a Tenancy Every Night
Overview
Administrators can use the Dekko DEMS S3 Gateway to keep a nightly copy of a tenancy's evidence files on a Windows server that your organisation runs. This article sets it up from start to finish: a backup account in DekkoDEMS, the gateway as a Windows service, a nightly rclone job, and a restore.
For the end-user steps, see S3 Gateway: Install and Create a Token.
This is an example setup. Test the schedule, retention and restore in your own environment before you rely on it.
How the backup works
A dedicated DekkoDEMS account, the backup account, is a member of the groups that your cases are shared with. One token for that account reaches the tenancy. The gateway shows the tenancy as a bucket and each case as a folder named by its ID #, and a nightly rclone job copies them all to the server.
| Who | Where | Steps |
|---|---|---|
| A DekkoDEMS administrator | DekkoDEMS, Tenancy | 1 and 2, once |
| A server administrator | The backup server | 3, 7 and 8, once |
| The backup account | DekkoDEMS and the backup server | 4 to 6, once |
| Task Scheduler | The backup server | Runs the backup every night |
Four limits apply:
- Only cases shared with the backup account's groups are backed up. The gateway reaches a case only through the account's group memberships. A case shared with the account directly, rather than with one of its groups, is not backed up, and neither are files shared with it below case level.
- Files and folders only. The backup holds each case's files and folders. Case attributes, content tags, case notes and the case audit stay in DekkoDEMS. To keep an audit record, see Case Audit.
- It is a copy of what is shared now. When a file is deleted in DekkoDEMS, a case is no longer shared with the backup account's groups, or the account leaves a group, the next run moves the local copy to an archive folder. The copy on your server, with its archive folders, is the backup.
- Required content tags block uploads. This does not affect the backup itself, which only downloads. It does affect restoring through S3 (see Restore a file).
What you need
- A DekkoDEMS administrator's sign-in.
- A Windows server or virtual machine, and a standard Windows account for the backup, not an administrator. This article calls it
BACKUPVM\demsbackup. The gateway's service refuses an administrator account. - The Dekko DEMS S3 Gateway for Windows (x64), DekkoDemsS3Gateway-win-x64.zip.
- rclone for Windows. This article uses
C:\tools\rclone\rclone.exe. - A data disk encrypted with BitLocker, with room for the evidence files and the archive. This article uses
D:\DemsBackup.
Step 1: Create the backup account and share cases with it
As a DekkoDEMS administrator:
Create a user for the backup, for example Central Backup. See Users and Groups.
Add it to every group that the cases you want to back up are shared with.
Check that each of those cases is shared with one of those groups at case level. See Creating and Sharing Cases.
The backup reaches cases only through the account's group memberships. Do not share cases with the backup account directly: those cases are not backed up.
Give the account's sign-in only to the person who runs the backup server, and use the account for nothing else.
Step 2: Allow the S3 gateway
Go to Tenancy → Policies, turn on Allow local S3 gateway, and save. Without it, the backup account cannot create a token. Turning the policy off closes the tenancy to every gateway. It does not delete people's tokens.
Step 3: Prepare the server
A server administrator does this once:
Create the folder
C:\Program Files\Dekko DEMS S3 Gatewayand copy or extract everything inside the ZIP file's DekkoDemsS3Gateway folder into it.Copy or extract the files there. Do not move a folder there: a moved folder keeps permissions that let other programs change it, and the gateway then refuses to set up the service.
Give the backup account the right to run scheduled tasks. Open Local Security Policy (
secpol.msc) → Local Policies → User Rights Assignment, open Log on as a batch job, and add the backup account.Install rclone in
C:\tools\rclone.Create the backup folders and let the backup account write to them, in PowerShell as an administrator:
New-Item -ItemType Directory -Force D:\DemsBackup, D:\DemsBackup\current, D:\DemsBackup\archive, D:\DemsBackup\logs icacls D:\DemsBackup /grant "BACKUPVM\demsbackup:(OI)(CI)M"
Step 4: Create the token and add it to the gateway
Sign in to Windows on the server as the backup account and start C:\Program Files\Dekko DEMS S3 Gateway\DekkoDemsS3Gateway.exe. Then, in a browser on the same server:
- Sign in to DekkoDEMS as the backup account, and check that its case list shows the cases you want to back up, through its groups.
- Go to Settings → S3 gateway and click New token.
- Enter a name, for example Backup server, and under Reaches choose the tenancy.
- Confirm with the account's password, click Create token, and click Copy token. It is shown only once.
- Within 5 minutes, paste it into the gateway window and click Add.
A DEMS token can read and upload, and can never replace or delete a file in DekkoDEMS. The backup job only downloads.
Step 5: Run the gateway as a Windows service
In the gateway window, still signed in as the backup account:
- Tick Run as a Windows service.
- Windows asks for an administrator's approval, then for the backup account's own Windows password. The service signs in as that account so that it can open its token.
The gateway now answers after a restart and while nobody is signed in, at the same address as before, and the backup account can sign out of Windows.
Step 6: Configure rclone
Create D:\DemsBackup\rclone.conf, using the gateway window's Copy buttons for the keys, endpoint and region:
[dems]
type = s3
provider = Other
endpoint = http://127.0.0.1:9593
region = ap-southeast-2
force_path_style = true
access_key_id = <Access key ID from the gateway window>
secret_access_key = <Secret access key from the gateway window>
Make the file readable only by the backup account and administrators:
icacls D:\DemsBackup\rclone.conf /inheritance:r /grant:r "BACKUPVM\demsbackup:(R,W)" "Administrators:F"
Check that rclone sees the tenancy as a bucket, and the cases inside it:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf lsd dems:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf lsd dems:<bucket>
Replace <bucket> with the name from the first command, for example metro-csi.
Step 7: Create the nightly job
Save this as D:\DemsBackup\backup.ps1:
$ErrorActionPreference = 'Stop'
$run = '{0:yyyy-MM-dd_HHmmss}_{1}' -f (Get-Date), [guid]::NewGuid().ToString('N').Substring(0,8)
& C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf sync dems: D:\DemsBackup\current `
--backup-dir "D:\DemsBackup\archive\$run" `
--transfers 8 --checkers 16 --multi-thread-streams 8 `
--log-file "D:\DemsBackup\logs\$run.log" --log-level INFO
exit $LASTEXITCODE
Each run makes current match the tenancy, with one folder per case. A file the run would replace or delete is first moved into a folder under archive named for that run. Each run writes its own log, and a failed run returns its error code to Task Scheduler.
Keep the direction as shown: from dems: to D:\DemsBackup\current. The sync deletes files on the server side only, and a DEMS token cannot delete or replace anything in DekkoDEMS.
Step 8: Schedule the job
Run this once in PowerShell as an administrator. It runs the job every night at 02:00 as the backup account, whether or not anyone is signed in:
$account = Get-Credential BACKUPVM\demsbackup
Register-ScheduledTask -TaskName "DEMS daily backup" -User $account.UserName `
-Password $account.GetNetworkCredential().Password -RunLevel Limited `
-Trigger (New-ScheduledTaskTrigger -Daily -At 2am) `
-Action (New-ScheduledTaskAction -Execute powershell.exe `
-Argument "-NoProfile -ExecutionPolicy Bypass -File D:\DemsBackup\backup.ps1")
To try it now, run Start-ScheduledTask "DEMS daily backup", then Get-ScheduledTaskInfo "DEMS daily backup". A LastTaskResult of 0 means it worked. 267011 means the task has not run, usually because the account is missing Log on as a batch job (Step 3).
What each night's run does
| Change in DekkoDEMS since the last run | What the run does |
|---|---|
| First run | Downloads every file in every case shared with the backup account's groups. |
| Nothing changed | Downloads nothing. |
| A new case shared with one of its groups, or new files in a case | Downloads them. |
| A file deleted, a case no longer shared with its groups, or the account removed from a group | Moves the local copy into that run's archive folder. |
rclone compares each file's size and modification time, so a run downloads only new and changed files. It still lists every file in every case, so runs take longer as the tenancy grows. Evidence such as video can be very large, so time the first run. A file uploaded and deleted between two runs is never copied.
Restore a file
- Deleted in DekkoDEMS recently: restore it in DekkoDEMS first. See Deleting and Restoring Content.
- On the server: copy the file from
D:\DemsBackup\current, or an earlier copy from a folder underD:\DemsBackup\archive. - Back into DekkoDEMS: a member of the case uploads it in the web app, where content tags and capture context are recorded. Uploading through S3 also works, into an existing case, but only if no content tag is Required, and an upload never replaces a file of the same name. A case cannot be created through S3: if the whole case was deleted, create a new case in DekkoDEMS (it gets a new ID #) and upload into it.
Check that the copy is complete
Once a week, compare the copy with DekkoDEMS:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf check dems: D:\DemsBackup\current --download --one-way
This reads every file from DekkoDEMS again, so it takes as long as a full download. It checks current only, not the archive folders.
Keep it running
- Backup account's Windows password changed: the service and the task stop signing in. Clear Run as a Windows service and tick it again, and register the task again with the new password.
- New gateway version: clear the box, then an administrator deletes
C:\Program Files\Dekko DEMS S3 Gatewayand copies the new version there as in Step 3. Start it from there and tick the box again. - New token: remove the old one in the gateway window and add the new one. The keys change, so update
rclone.conf. Then revoke the old token in DekkoDEMS under Settings → S3 gateway. Removing it from the gateway window does not revoke it. - New cases and groups: a new case is backed up only if it is shared with one of the backup account's groups. When you create a new group that cases are shared with, add the backup account to it.
- Remove the service: clear the box. If the folder was deleted first, an administrator runs
sc.exe delete DekkoDemsS3Gateway. To remove the gateway completely, see Uninstall the gateway.
Uninstall the gateway
Uninstalling the gateway does not delete any files in DekkoDEMS, or files your S3 app has copied to your computer.
On the backup server, signed in to Windows as the backup account:
- Clear Run as a Windows service in the gateway window first.
- Remove the nightly task, in PowerShell as an administrator:
Unregister-ScheduledTask "DEMS daily backup" -Confirm:$false. - Run the uninstaller as the backup account, so that it can remove the token saved in that account's Windows profile. If it says it could not remove something, such as the program folder, run it again as an administrator.
- Download and run the Dekko Uninstaller. It opens a window titled Dekko Apps Uninstaller.
- To check first what it would remove, type 2 and press Enter. Nothing is changed. Options 1 and 2 search every drive, so they can take a few minutes.
- Type 1 and press Enter to uninstall. If more than one Dekko app is installed, the uninstaller lists them. Type the number of Dekko S3 Gateway (DEMS) and press Enter. To remove several, type their numbers, such as 1,3, or A for all of them.
- Type delete and press Enter to go ahead. Anything else stops without removing anything.
- The uninstaller lists what it removed and shows where your files are. It does not delete them. If it offers to open that folder, type y to open it or n to skip.
- Type Q and press Enter to close the uninstaller.
Then, in DekkoDEMS, sign in as the backup account and revoke the server's token under Settings → S3 gateway.
The uninstaller does not touch rclone, rclone.conf or the backup folders. Delete D:\DemsBackup yourself when you no longer need the copy.
Protect the backup
- The gateway decrypts files on the server, so the copy on its disk is readable. Encrypt that disk with BitLocker.
- Limit who can sign in to the server.
- Keep
rclone.confreadable only by the backup account and administrators. Anyone who can read it, and reach the gateway on the server, can read every case the backup account can. - Keep the backup account's DekkoDEMS password with the server team only, and use it for nothing else.
- Keep a second copy on other storage, so one disk failing does not take both.
- Decide how long to keep archive folders, in line with your evidence retention rules. The job never deletes them, so they grow until you remove old ones.
Test before you rely on it
- Restart the server, sign nobody in, and let a scheduled run happen.
- Make a transfer fail, and check how it shows in Task Scheduler and the log.
- Run a full backup of the tenancy and time it.
- Share a new case with one of the backup account's groups and check the next run copies it.
- Restore a file from an archive folder.
Optional: browse the backup with Brows3
To see the same cases and files in a window on the server, add a connection in Brows3 with the gateway's connection details. See S3 Gateway: Connect an S3 App (Brows3).
How the backup works
A dedicated DekkoDEMS account, the backup account, is a member of the groups that your cases are shared with. One token for that account reaches the tenancy. The gateway shows the tenancy as a bucket and each case as a folder named by its ID #, and a nightly rclone job copies them all to the server.
| Who | Where | Steps |
|---|---|---|
| A DekkoDEMS administrator | DekkoDEMS, Tenancy | 1 and 2, once |
| A server administrator | The backup server | 3, 7 and 8, once |
| The backup account | DekkoDEMS and the backup server | 4 to 6, once |
| Task Scheduler | The backup server | Runs the backup every night |
Four limits apply:
- Only cases shared with the backup account's groups are backed up. The gateway reaches a case only through the account's group memberships. A case shared with the account directly, rather than with one of its groups, is not backed up, and neither are files shared with it below case level.
- Files and folders only. The backup holds each case's files and folders. Case attributes, content tags, case notes and the case audit stay in DekkoDEMS. To keep an audit record, see Case Audit.
- It is a copy of what is shared now. When a file is deleted in DekkoDEMS, a case is no longer shared with the backup account's groups, or the account leaves a group, the next run moves the local copy to an archive folder. The copy on your server, with its archive folders, is the backup.
- Required content tags block uploads. This does not affect the backup itself, which only downloads. It does affect restoring through S3 (see Restore a file).
What you need
- A DekkoDEMS administrator's sign-in.
- A Windows server or virtual machine, and a standard Windows account for the backup, not an administrator. This article calls it
BACKUPVM\demsbackup. The gateway's service refuses an administrator account. - The Dekko DEMS S3 Gateway for Windows (x64), DekkoDemsS3Gateway-win-x64.zip.
- rclone for Windows. This article uses
C:\tools\rclone\rclone.exe. - A data disk encrypted with BitLocker, with room for the evidence files and the archive. This article uses
D:\DemsBackup.
Step 1: Create the backup account and share cases with it
As a DekkoDEMS administrator:
Create a user for the backup, for example Central Backup. See Users and Groups.
Add it to every group that the cases you want to back up are shared with.
Check that each of those cases is shared with one of those groups at case level. See Creating and Sharing Cases.
The backup reaches cases only through the account's group memberships. Do not share cases with the backup account directly: those cases are not backed up.
Give the account's sign-in only to the person who runs the backup server, and use the account for nothing else.
Step 2: Allow the S3 gateway
Go to Tenancy → Policies, turn on Allow local S3 gateway, and save. Without it, the backup account cannot create a token. Turning the policy off closes the tenancy to every gateway. It does not delete people's tokens.
Step 3: Prepare the server
A server administrator does this once:
Create the folder
C:\Program Files\Dekko DEMS S3 Gatewayand copy or extract everything inside the ZIP file's DekkoDemsS3Gateway folder into it.Copy or extract the files there. Do not move a folder there: a moved folder keeps permissions that let other programs change it, and the gateway then refuses to set up the service.
Give the backup account the right to run scheduled tasks. Open Local Security Policy (
secpol.msc) → Local Policies → User Rights Assignment, open Log on as a batch job, and add the backup account.Install rclone in
C:\tools\rclone.Create the backup folders and let the backup account write to them, in PowerShell as an administrator:
New-Item -ItemType Directory -Force D:\DemsBackup, D:\DemsBackup\current, D:\DemsBackup\archive, D:\DemsBackup\logs icacls D:\DemsBackup /grant "BACKUPVM\demsbackup:(OI)(CI)M"
Step 4: Create the token and add it to the gateway
Sign in to Windows on the server as the backup account and start C:\Program Files\Dekko DEMS S3 Gateway\DekkoDemsS3Gateway.exe. Then, in a browser on the same server:
- Sign in to DekkoDEMS as the backup account, and check that its case list shows the cases you want to back up, through its groups.
- Go to Settings → S3 gateway and click New token.
- Enter a name, for example Backup server, and under Reaches choose the tenancy.
- Confirm with the account's password, click Create token, and click Copy token. It is shown only once.
- Within 5 minutes, paste it into the gateway window and click Add.
A DEMS token can read and upload, and can never replace or delete a file in DekkoDEMS. The backup job only downloads.
Step 5: Run the gateway as a Windows service
In the gateway window, still signed in as the backup account:
- Tick Run as a Windows service.
- Windows asks for an administrator's approval, then for the backup account's own Windows password. The service signs in as that account so that it can open its token.
The gateway now answers after a restart and while nobody is signed in, at the same address as before, and the backup account can sign out of Windows.
Step 6: Configure rclone
Create D:\DemsBackup\rclone.conf, using the gateway window's Copy buttons for the keys, endpoint and region:
[dems]
type = s3
provider = Other
endpoint = http://127.0.0.1:9593
region = ap-southeast-2
force_path_style = true
access_key_id = <Access key ID from the gateway window>
secret_access_key = <Secret access key from the gateway window>
Make the file readable only by the backup account and administrators:
icacls D:\DemsBackup\rclone.conf /inheritance:r /grant:r "BACKUPVM\demsbackup:(R,W)" "Administrators:F"
Check that rclone sees the tenancy as a bucket, and the cases inside it:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf lsd dems:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf lsd dems:<bucket>
Replace <bucket> with the name from the first command, for example metro-csi.
Step 7: Create the nightly job
Save this as D:\DemsBackup\backup.ps1:
$ErrorActionPreference = 'Stop'
$run = '{0:yyyy-MM-dd_HHmmss}_{1}' -f (Get-Date), [guid]::NewGuid().ToString('N').Substring(0,8)
& C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf sync dems: D:\DemsBackup\current `
--backup-dir "D:\DemsBackup\archive\$run" `
--transfers 8 --checkers 16 --multi-thread-streams 8 `
--log-file "D:\DemsBackup\logs\$run.log" --log-level INFO
exit $LASTEXITCODE
Each run makes current match the tenancy, with one folder per case. A file the run would replace or delete is first moved into a folder under archive named for that run. Each run writes its own log, and a failed run returns its error code to Task Scheduler.
Keep the direction as shown: from dems: to D:\DemsBackup\current. The sync deletes files on the server side only, and a DEMS token cannot delete or replace anything in DekkoDEMS.
Step 8: Schedule the job
Run this once in PowerShell as an administrator. It runs the job every night at 02:00 as the backup account, whether or not anyone is signed in:
$account = Get-Credential BACKUPVM\demsbackup
Register-ScheduledTask -TaskName "DEMS daily backup" -User $account.UserName `
-Password $account.GetNetworkCredential().Password -RunLevel Limited `
-Trigger (New-ScheduledTaskTrigger -Daily -At 2am) `
-Action (New-ScheduledTaskAction -Execute powershell.exe `
-Argument "-NoProfile -ExecutionPolicy Bypass -File D:\DemsBackup\backup.ps1")
To try it now, run Start-ScheduledTask "DEMS daily backup", then Get-ScheduledTaskInfo "DEMS daily backup". A LastTaskResult of 0 means it worked. 267011 means the task has not run, usually because the account is missing Log on as a batch job (Step 3).
What each night's run does
| Change in DekkoDEMS since the last run | What the run does |
|---|---|
| First run | Downloads every file in every case shared with the backup account's groups. |
| Nothing changed | Downloads nothing. |
| A new case shared with one of its groups, or new files in a case | Downloads them. |
| A file deleted, a case no longer shared with its groups, or the account removed from a group | Moves the local copy into that run's archive folder. |
rclone compares each file's size and modification time, so a run downloads only new and changed files. It still lists every file in every case, so runs take longer as the tenancy grows. Evidence such as video can be very large, so time the first run. A file uploaded and deleted between two runs is never copied.
Restore a file
- Deleted in DekkoDEMS recently: restore it in DekkoDEMS first. See Deleting and Restoring Content.
- On the server: copy the file from
D:\DemsBackup\current, or an earlier copy from a folder underD:\DemsBackup\archive. - Back into DekkoDEMS: a member of the case uploads it in the web app, where content tags and capture context are recorded. Uploading through S3 also works, into an existing case, but only if no content tag is Required, and an upload never replaces a file of the same name. A case cannot be created through S3: if the whole case was deleted, create a new case in DekkoDEMS (it gets a new ID #) and upload into it.
Check that the copy is complete
Once a week, compare the copy with DekkoDEMS:
C:\tools\rclone\rclone.exe --config D:\DemsBackup\rclone.conf check dems: D:\DemsBackup\current --download --one-way
This reads every file from DekkoDEMS again, so it takes as long as a full download. It checks current only, not the archive folders.
Keep it running
- Backup account's Windows password changed: the service and the task stop signing in. Clear Run as a Windows service and tick it again, and register the task again with the new password.
- New gateway version: clear the box, then an administrator deletes
C:\Program Files\Dekko DEMS S3 Gatewayand copies the new version there as in Step 3. Start it from there and tick the box again. - New token: remove the old one in the gateway window and add the new one. The keys change, so update
rclone.conf. Then revoke the old token in DekkoDEMS under Settings → S3 gateway. Removing it from the gateway window does not revoke it. - New cases and groups: a new case is backed up only if it is shared with one of the backup account's groups. When you create a new group that cases are shared with, add the backup account to it.
- Remove the service: clear the box. If the folder was deleted first, an administrator runs
sc.exe delete DekkoDemsS3Gateway.
Protect the backup
- The gateway decrypts files on the server, so the copy on its disk is readable. Encrypt that disk with BitLocker.
- Limit who can sign in to the server.
- Keep
rclone.confreadable only by the backup account and administrators. Anyone who can read it, and reach the gateway on the server, can read every case the backup account can. - Keep the backup account's DekkoDEMS password with the server team only, and use it for nothing else.
- Keep a second copy on other storage, so one disk failing does not take both.
- Decide how long to keep archive folders, in line with your evidence retention rules. The job never deletes them, so they grow until you remove old ones.
Test before you rely on it
- Restart the server, sign nobody in, and let a scheduled run happen.
- Make a transfer fail, and check how it shows in Task Scheduler and the log.
- Run a full backup of the tenancy and time it.
- Share a new case with one of the backup account's groups and check the next run copies it.
- Restore a file from an archive folder.
Optional: browse the backup with Brows3
To see the same cases and files in a window on the server, add a connection in Brows3 with the gateway's connection details. See S3 Gateway: Connect an S3 App (Brows3).