refactor: add default excludes to backups (#178)
- To avoid accidentaly backing up a repository to itself - To avoid accidentaly backing up zerobyte's internal data
This commit is contained in:
parent
fd5193b5e3
commit
6a86de7b95
2 changed files with 11 additions and 1 deletions
|
|
@ -4,4 +4,10 @@ export const REPOSITORY_BASE = "/var/lib/zerobyte/repositories";
|
||||||
export const DATABASE_URL = "/var/lib/zerobyte/data/ironmount.db";
|
export const DATABASE_URL = "/var/lib/zerobyte/data/ironmount.db";
|
||||||
export const RESTIC_PASS_FILE = "/var/lib/zerobyte/data/restic.pass";
|
export const RESTIC_PASS_FILE = "/var/lib/zerobyte/data/restic.pass";
|
||||||
|
|
||||||
|
export const DEFAULT_EXCLUDES = [
|
||||||
|
DATABASE_URL,
|
||||||
|
RESTIC_PASS_FILE,
|
||||||
|
"/var/lib/zerobyte/repositories/**", // To avoid circular backups
|
||||||
|
];
|
||||||
|
|
||||||
export const REQUIRED_MIGRATIONS = ["v0.14.0"];
|
export const REQUIRED_MIGRATIONS = ["v0.14.0"];
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import os from "node:os";
|
||||||
import { throttle } from "es-toolkit";
|
import { throttle } from "es-toolkit";
|
||||||
import { type } from "arktype";
|
import { type } from "arktype";
|
||||||
import { $ } from "bun";
|
import { $ } from "bun";
|
||||||
import { REPOSITORY_BASE, RESTIC_PASS_FILE } from "../core/constants";
|
import { REPOSITORY_BASE, RESTIC_PASS_FILE, DEFAULT_EXCLUDES } from "../core/constants";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { cryptoUtils } from "./crypto";
|
import { cryptoUtils } from "./crypto";
|
||||||
import type { RetentionPolicy } from "../modules/backups/backups.dto";
|
import type { RetentionPolicy } from "../modules/backups/backups.dto";
|
||||||
|
|
@ -275,6 +275,10 @@ const backup = async (
|
||||||
args.push(source);
|
args.push(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const exclude of DEFAULT_EXCLUDES) {
|
||||||
|
args.push("--exclude", exclude);
|
||||||
|
}
|
||||||
|
|
||||||
if (options?.exclude && options.exclude.length > 0) {
|
if (options?.exclude && options.exclude.length > 0) {
|
||||||
for (const pattern of options.exclude) {
|
for (const pattern of options.exclude) {
|
||||||
args.push("--exclude", pattern);
|
args.push("--exclude", pattern);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue