-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Note that this is "bleeding edge" functionality and that the newly added config option PHOTOPRISM_BACKUP_RETAIN can be set, but does not have any effect yet. Feedback welcome! Signed-off-by: Michael Mayer <[email protected]>
- Loading branch information
Showing
41 changed files
with
553 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,5 +39,5 @@ func TestStart(t *testing.T) { | |
ResetImport() | ||
ResetIndex() | ||
|
||
Stop() | ||
Shutdown() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package config | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/robfig/cron/v3" | ||
|
||
"github.com/photoprism/photoprism/pkg/fs" | ||
) | ||
|
||
const ( | ||
DefaultBackupSchedule = "0 12 * * *" | ||
DefaultBackupRetain = 14 | ||
) | ||
|
||
// BackupPath returns the backup storage path. | ||
func (c *Config) BackupPath() string { | ||
if fs.PathWritable(c.options.BackupPath) { | ||
return fs.Abs(c.options.BackupPath) | ||
} | ||
|
||
return filepath.Join(c.StoragePath(), "backup") | ||
} | ||
|
||
// BackupIndex checks if index SQL database dumps should be created based on the configured schedule. | ||
func (c *Config) BackupIndex() bool { | ||
return c.options.BackupIndex | ||
} | ||
|
||
// BackupAlbums checks if album YAML file backups should be created based on the configured schedule. | ||
func (c *Config) BackupAlbums() bool { | ||
return c.options.BackupAlbums | ||
} | ||
|
||
// BackupRetain returns the maximum number of SQL database dumps to keep, or -1 to keep all. | ||
func (c *Config) BackupRetain() int { | ||
if c.options.BackupRetain == 0 { | ||
return DefaultBackupRetain | ||
} else if c.options.BackupRetain < -1 { | ||
return -1 | ||
} | ||
|
||
return c.options.BackupRetain | ||
} | ||
|
||
// BackupSchedule returns the backup schedule in cron format, e.g. "0 12 * * *" for daily at noon. | ||
func (c *Config) BackupSchedule() string { | ||
if c.options.BackupSchedule == "" { | ||
return "" | ||
} else if _, err := cron.ParseStandard(c.options.BackupSchedule); err != nil { | ||
log.Tracef("config: invalid backup schedule (%s)", err) | ||
return "" | ||
} | ||
|
||
return c.options.BackupSchedule | ||
} |
Oops, something went wrong.
0e7c91f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see: