From cc93a94e15f263377c3c4048547ae952ab95fc9f Mon Sep 17 00:00:00 2001 From: astro-stan <36302090+astro-stan@users.noreply.github.com> Date: Sun, 28 Jun 2026 14:36:58 +0100 Subject: [PATCH] feat: Add support for setting `--ignore-ctime` and `--ignore-inode` via environment variables (#5730) --- cmd/restic/cmd_backup.go | 8 ++++++-- doc/075_scripting.rst | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 86cdbe3a4..04f2df367 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -128,8 +128,8 @@ func (opts *BackupOptions) AddFlags(f *pflag.FlagSet) { f.StringArrayVar(&opts.FilesFromRaw, "files-from-raw", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)") f.StringVar(&opts.TimeStamp, "time", "", "`time` of the backup (ex. '2012-11-01 22:08:41') (default: now)") f.BoolVar(&opts.WithAtime, "with-atime", false, "store the atime for all files and directories") - f.BoolVar(&opts.IgnoreInode, "ignore-inode", false, "ignore inode number and ctime changes when checking for modified files") - f.BoolVar(&opts.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files") + f.BoolVar(&opts.IgnoreInode, "ignore-inode", false, "ignore inode number and ctime changes when checking for modified files (default: $RESTIC_IGNORE_INODE or false)") + f.BoolVar(&opts.IgnoreCtime, "ignore-ctime", false, "ignore ctime changes when checking for modified files (default: $RESTIC_IGNORE_CTIME or false)") f.BoolVarP(&opts.DryRun, "dry-run", "n", false, "do not upload or write any data, just show what would be done") f.BoolVar(&opts.NoScan, "no-scan", false, "do not run scanner to estimate size of backup") if runtime.GOOS == "windows" { @@ -142,6 +142,10 @@ func (opts *BackupOptions) AddFlags(f *pflag.FlagSet) { opts.readConcurrencyFlag = f.Lookup("read-concurrency") + // parse read inode and ctime from env, on error the default value will be used + opts.IgnoreInode, _ = strconv.ParseBool(os.Getenv("RESTIC_IGNORE_INODE")) + opts.IgnoreCtime, _ = strconv.ParseBool(os.Getenv("RESTIC_IGNORE_CTIME")) + // parse host from env, if not exists or empty the default value will be used if host := os.Getenv("RESTIC_HOST"); host != "" { opts.Host = host diff --git a/doc/075_scripting.rst b/doc/075_scripting.rst index a92e52896..cd16bb282 100644 --- a/doc/075_scripting.rst +++ b/doc/075_scripting.rst @@ -41,6 +41,8 @@ environment variables, which are listed below. RESTIC_PROGRESS_FPS Frames per second by which the progress bar is updated RESTIC_PACK_SIZE Target size for pack files RESTIC_READ_CONCURRENCY Concurrency for file reads + RESTIC_IGNORE_CTIME Ignore ctime changes when comparing files (replaces --ignore-ctime) + RESTIC_IGNORE_INODE Ignore inode changes when comparing files (replaces --ignore-inode) RESTIC_FROM_REPOSITORY Source repository for copy (replaces --from-repo) RESTIC_FROM_REPOSITORY_FILE File containing source repository for copy (replaces --from-repository-file)