Files
duplicati/Duplicati/CommandLine/DatabaseTool/Scripts/Local/18. Remove object lock expiration from remotevolume.sql
T
Kenneth Skovhede 0f81b42146 Add support for remote locks
This PR adds support for locking files if the backend supports it.

To activate locking, set the option `--file-lock-duration=30D` and the backup will lock the files.

If the database is rebuilt with the intention of continuing the backups, use the option `--repair-refresh-lock-info` which will update lock information in the database after recreating the database.

The locking works by asking the backend to lock files after a backup has completed.

The implementation keeps track of which files are currently assigned a lock and prevents attempting to delete the files that are currently locked.

Note that the bucket should not have a default lock policy as Duplicati needs to finish the backup before the locking is applied.

In this initial version, Azure Blob Storage, B2, S3 and iDrive are supported with locking.

The CLI is updated to allow setting locks on a specific version. The backend tool is updated to allow setting locks on specific files.
2025-12-14 17:17:48 +01:00

30 lines
1.1 KiB
SQL

CREATE TEMPORARY TABLE "RemoteVolumeTemp" AS
SELECT "ID", "OperationID", "Name", "Type", "Size", "Hash", "State", "VerificationCount", "DeleteGraceTime", "ArchiveTime"
FROM "RemoteVolume";
DROP INDEX IF EXISTS "RemotevolumeName";
DROP INDEX IF EXISTS "RemotevolumeNameOnly";
DROP TABLE "RemoteVolume";
CREATE TABLE "Remotevolume" (
"ID" INTEGER PRIMARY KEY,
"OperationID" INTEGER NOT NULL,
"Name" TEXT NOT NULL,
"Type" TEXT NOT NULL,
"Size" INTEGER NULL,
"Hash" TEXT NULL,
"State" TEXT NOT NULL,
"VerificationCount" INTEGER NOT NULL,
"DeleteGraceTime" INTEGER NOT NULL,
"ArchiveTime" INTEGER NOT NULL
);
INSERT INTO "Remotevolume"("ID", "OperationID", "Name", "Type", "Size", "Hash", "State", "VerificationCount", "DeleteGraceTime", "ArchiveTime")
SELECT "ID", "OperationID", "Name", "Type", "Size", "Hash", "State", "VerificationCount", "DeleteGraceTime", "ArchiveTime"
FROM "RemoteVolumeTemp";
DROP TABLE "RemoteVolumeTemp";
CREATE UNIQUE INDEX IF NOT EXISTS "RemotevolumeNameOnly" ON "Remotevolume" ("Name");
CREATE UNIQUE INDEX "RemotevolumeName" ON "Remotevolume" ("Name", "State");