diff --git a/src/cmds/restic/cmd_backup.go b/src/cmds/restic/cmd_backup.go index 29a4ec8e6..f15851331 100644 --- a/src/cmds/restic/cmd_backup.go +++ b/src/cmds/restic/cmd_backup.go @@ -66,7 +66,7 @@ func init() { f.StringVar(&backupOptions.ExcludeFile, "exclude-file", "", "read exclude patterns from a file") f.BoolVarP(&backupOptions.ExcludeOtherFS, "one-file-system", "x", false, "Exclude other file systems") f.BoolVar(&backupOptions.Stdin, "stdin", false, "read backup from stdin") - f.StringVar(&backupOptions.StdinFilename, "stdin-filename", "", "file name to use when reading from stdin") + f.StringVar(&backupOptions.StdinFilename, "stdin-filename", "stdin", "file name to use when reading from stdin") f.StringSliceVar(&backupOptions.Tags, "tag", []string{}, "add a `tag` for the new snapshot (can be specified multiple times)") f.StringVar(&backupOptions.FilesFrom, "files-from", "", "read the files to backup from file (can be combined with file args)") } @@ -240,6 +240,10 @@ func readBackupFromStdin(opts BackupOptions, gopts GlobalOptions, args []string) return errors.Fatalf("when reading from stdin, no additional files can be specified") } + if opts.StdinFilename == "" { + return errors.Fatal("filename for backup from stdin must not be empty") + } + if gopts.password == "" && gopts.PasswordFile == "" { return errors.Fatal("unable to read password from stdin when data is to be read from stdin, use --password-file or $RESTIC_PASSWORD") } diff --git a/src/restic/archiver/archive_reader.go b/src/restic/archiver/archive_reader.go index 22158fbe3..713799a04 100644 --- a/src/restic/archiver/archive_reader.go +++ b/src/restic/archiver/archive_reader.go @@ -14,6 +14,10 @@ import ( // ArchiveReader reads from the reader and archives the data. Returned is the // resulting snapshot and its ID. func ArchiveReader(repo restic.Repository, p *restic.Progress, rd io.Reader, name string, tags []string) (*restic.Snapshot, restic.ID, error) { + if name == "" { + return nil, restic.ID{}, errors.New("no filename given") + } + debug.Log("start archiving %s", name) sn, err := restic.NewSnapshot([]string{name}, tags) if err != nil {