-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config: Add “daily” and “weekly” backup schedule options #4243
Signed-off-by: Michael Mayer <michael@photoprism.app>
- Loading branch information
Showing
22 changed files
with
394 additions
and
266 deletions.
There are no files selected for viewing
63 changes: 61 additions & 2 deletions
63
internal/photoprism/restore_albums.go → internal/backup/albums.go
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,35 @@ | ||
package backup | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/photoprism/photoprism/pkg/fs" | ||
) | ||
|
||
func TestAlbums(t *testing.T) { | ||
backupPath, err := filepath.Abs("./testdata/albums") | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if err = os.MkdirAll(backupPath, fs.ModeDir); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
count, err := Albums(backupPath, true) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.Equal(t, 30, count) | ||
|
||
if err = os.RemoveAll(backupPath); err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
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,31 @@ | ||
/* | ||
Package backup provides backup and restore functions for databases and albums. | ||
Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved. | ||
This program is free software: you can redistribute it and/or modify | ||
it under Version 3 of the GNU Affero General Public License (the "AGPL"): | ||
<https://docs.photoprism.app/license/agpl> | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
The AGPL is supplemented by our Trademark and Brand Guidelines, | ||
which describe how our Brand Assets may be used: | ||
<https://www.photoprism.app/trademark> | ||
Feel free to send an email to hello@photoprism.app if you have questions, | ||
want to support our work, or just want to say hello. | ||
Additional information can be found in our Developer Guide: | ||
<https://docs.photoprism.app/developer-guide/> | ||
*/ | ||
package backup | ||
|
||
import ( | ||
"github.com/photoprism/photoprism/internal/event" | ||
) | ||
|
||
var log = event.Log |
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,29 @@ | ||
package backup | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/photoprism/photoprism/internal/config" | ||
"github.com/photoprism/photoprism/internal/event" | ||
"github.com/photoprism/photoprism/internal/get" | ||
"github.com/photoprism/photoprism/internal/photoprism" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
log = logrus.StandardLogger() | ||
log.SetLevel(logrus.TraceLevel) | ||
event.AuditLog = log | ||
|
||
c := config.TestConfig() | ||
defer c.CloseDb() | ||
|
||
get.SetConfig(c) | ||
photoprism.SetConfig(c) | ||
|
||
code := m.Run() | ||
|
||
os.Exit(code) | ||
} |
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,3 @@ | ||
package backup | ||
|
||
const SqlBackupFileNamePattern = "[2-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9].sql" |
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,12 @@ | ||
package backup | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
) | ||
|
||
var ( | ||
backupDatabaseMutex = sync.Mutex{} | ||
backupAlbumsMutex = sync.Mutex{} | ||
backupAlbumsTime = time.Time{} | ||
) |
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,2 @@ | ||
* | ||
!.gitignore |
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
Oops, something went wrong.