diff --git a/backup/backup.go b/backup/backup.go index fc46ede..c62cca1 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -98,6 +98,14 @@ func findGzCommand() string { // Run stops Plex, performs the backup, then starts Plex again. // It should ideally be run soon after the server maintenance period. func (o *Opts) Run(svc *s3.S3) error { + fi, err := os.Stat(o.Directory) + if err != nil { + return err + } + if !fi.IsDir() { + return fmt.Errorf("%v is not a directory", o.Directory) + } + oldest, err := oldestObject(svc, o.Bucket, o.Prefix) if err != nil { return fmt.Errorf("failed to retrieve oldest backup: %v", err) diff --git a/main.go b/main.go index 06bfbcd..c2a055e 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ var ( String() directory = kingpin.Flag("directory", "Location of the 'Plex Media Server' directory to back up."). Default("/var/lib/plexmediaserver/Library/Application Support/Plex Media Server"). - ExistingDir() + String() ) func main() {