Config: Add backup path parameter
This commit is contained in:
parent
8ea5a882b4
commit
3464bf35ed
2
Makefile
2
Makefile
|
@ -157,7 +157,7 @@ clean:
|
|||
rm -f *.log
|
||||
rm -rf node_modules
|
||||
rm -rf storage/testdata
|
||||
rm -rf storage/backups
|
||||
rm -rf storage/backup
|
||||
rm -rf storage/cache
|
||||
rm -rf frontend/node_modules
|
||||
docker-development:
|
||||
|
|
|
@ -134,12 +134,12 @@ RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/psampaz/go-mod-ou
|
|||
|
||||
# Create photoprism user and directory for deployment
|
||||
RUN useradd photoprism -m -d /photoprism && \
|
||||
chmod 777 /photoprism && \
|
||||
mkdir -p /var/lib/photoprism && \
|
||||
echo "alias go=richgo" > /photoprism/.bash_aliases && \
|
||||
echo "photoprism ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
|
||||
chown -R photoprism:photoprism /photoprism && \
|
||||
find /go -type d -print0 | xargs -0 chmod 777 && \
|
||||
find /go -type f -print0 | xargs -0 chmod a+rw
|
||||
chown -R photoprism:photoprism /photoprism /var/lib/photoprism && \
|
||||
chmod -R a+rw /photoprism /var/lib/photoprism /go && \
|
||||
find /go -type d -print0 | xargs -0 chmod 777
|
||||
|
||||
# Copy mysql client config for development
|
||||
COPY --chown=root:root /docker/development/.my.cnf /root/.my.cnf
|
||||
|
@ -151,6 +151,7 @@ WORKDIR "/go/src/github.com/photoprism/photoprism"
|
|||
|
||||
# Expose HTTP port 2342, 2343 plus 9515 for chromedriver
|
||||
EXPOSE 2342 2343 9515
|
||||
VOLUME /var/lib/photoprism
|
||||
|
||||
# Keep container running (services can be started manually using a terminal)
|
||||
CMD tail -f /dev/null
|
||||
|
|
|
@ -61,9 +61,10 @@ ENV TMPDIR /tmp
|
|||
|
||||
# Storage path names
|
||||
ENV PHOTOPRISM_ASSETS_PATH /photoprism/assets
|
||||
ENV PHOTOPRISM_STORAGE_PATH /photoprism/storage
|
||||
ENV PHOTOPRISM_BACKUP_PATH /var/lib/photoprism
|
||||
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
|
||||
ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
|
||||
ENV PHOTOPRISM_STORAGE_PATH /photoprism/storage
|
||||
ENV PHOTOPRISM_LOG_FILENAME /photoprism/photoprism.log
|
||||
ENV PHOTOPRISM_PID_FILENAME /photoprism/photoprism.pid
|
||||
|
||||
|
@ -100,12 +101,13 @@ COPY --from=build /root/.photoprism/assets /photoprism/assets
|
|||
|
||||
# Create directories
|
||||
RUN mkdir -p \
|
||||
/var/lib/photoprism \
|
||||
/photoprism/originals \
|
||||
/photoprism/import \
|
||||
/photoprism/storage/settings \
|
||||
/photoprism/storage/cache && \
|
||||
chown -R photoprism:photoprism /photoprism && \
|
||||
chmod -R a+rw /photoprism
|
||||
chown -R photoprism:photoprism /photoprism /var/lib/photoprism && \
|
||||
chmod -R a+rw /photoprism /var/lib/photoprism
|
||||
|
||||
# Show photoprism version
|
||||
RUN photoprism -v
|
||||
|
@ -116,6 +118,7 @@ EXPOSE 2342
|
|||
# Configure entrypoint
|
||||
COPY --chown=root:root /docker/entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
VOLUME /var/lib/photoprism
|
||||
|
||||
# Run server
|
||||
CMD ["photoprism", "start"]
|
||||
|
|
|
@ -147,9 +147,10 @@ ENV TMPDIR /tmp
|
|||
|
||||
# Storage path names
|
||||
ENV PHOTOPRISM_ASSETS_PATH /photoprism/assets
|
||||
ENV PHOTOPRISM_STORAGE_PATH /photoprism/storage
|
||||
ENV PHOTOPRISM_BACKUP_PATH /var/lib/photoprism
|
||||
ENV PHOTOPRISM_ORIGINALS_PATH /photoprism/originals
|
||||
ENV PHOTOPRISM_IMPORT_PATH /photoprism/import
|
||||
ENV PHOTOPRISM_STORAGE_PATH /photoprism/storage
|
||||
ENV PHOTOPRISM_LOG_FILENAME /photoprism/photoprism.log
|
||||
ENV PHOTOPRISM_PID_FILENAME /photoprism/photoprism.pid
|
||||
|
||||
|
@ -186,12 +187,13 @@ COPY --from=build /root/.photoprism/assets /photoprism/assets
|
|||
|
||||
# Create directories
|
||||
RUN mkdir -p \
|
||||
/var/lib/photoprism \
|
||||
/photoprism/originals \
|
||||
/photoprism/import \
|
||||
/photoprism/storage/settings \
|
||||
/photoprism/storage/cache && \
|
||||
chown -R photoprism:photoprism /photoprism && \
|
||||
chmod -R a+rw /photoprism
|
||||
chown -R photoprism:photoprism /photoprism /var/lib/photoprism && \
|
||||
chmod -R a+rw /photoprism /var/lib/photoprism
|
||||
|
||||
# Show photoprism version
|
||||
RUN photoprism -v
|
||||
|
@ -202,6 +204,7 @@ EXPOSE 2342
|
|||
# Configure entrypoint
|
||||
COPY --chown=root:root /docker/entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
VOLUME /var/lib/photoprism
|
||||
|
||||
# Run server
|
||||
CMD ["photoprism", "start"]
|
||||
|
|
|
@ -69,6 +69,7 @@ func configAction(ctx *cli.Context) error {
|
|||
// Main directories.
|
||||
fmt.Printf("%-25s %s\n", "assets-path", conf.AssetsPath())
|
||||
fmt.Printf("%-25s %s\n", "storage-path", conf.StoragePath())
|
||||
fmt.Printf("%-25s %s\n", "backup-path", conf.BackupPath())
|
||||
fmt.Printf("%-25s %s\n", "import-path", conf.ImportPath())
|
||||
fmt.Printf("%-25s %s\n", "originals-path", conf.OriginalsPath())
|
||||
fmt.Printf("%-25s %d\n", "originals-limit", conf.OriginalsLimit())
|
||||
|
|
|
@ -278,7 +278,7 @@ func (c *Config) OriginalsLimit() int64 {
|
|||
return c.params.OriginalsLimit * 1024 * 1024
|
||||
}
|
||||
|
||||
// UpdatePro updates photoprism.pro api credentials for maps & places.
|
||||
// UpdatePro updates backend api credentials for maps & places.
|
||||
func (c *Config) UpdatePro() {
|
||||
if err := c.pro.Refresh(); err != nil {
|
||||
log.Debugf("config: %s", err)
|
||||
|
@ -289,7 +289,7 @@ func (c *Config) UpdatePro() {
|
|||
}
|
||||
}
|
||||
|
||||
// initPro initializes photoprism.pro api credentials for maps & places.
|
||||
// initPro initializes backend api credentials for maps & places.
|
||||
func (c *Config) initPro() {
|
||||
c.pro = pro.NewConfig(c.Version(), c.ProConfigFile())
|
||||
|
||||
|
@ -315,7 +315,7 @@ func (c *Config) initPro() {
|
|||
}()
|
||||
}
|
||||
|
||||
// Config returns the photoprism.pro api credentials.
|
||||
// Config returns the backend api credentials.
|
||||
func (c *Config) Pro() *pro.Config {
|
||||
if c.pro == nil {
|
||||
c.initPro()
|
||||
|
|
|
@ -86,6 +86,12 @@ func TestConfig_SettingsPath(t *testing.T) {
|
|||
assert.Contains(t, c.SettingsPath(), "/storage/testdata/settings")
|
||||
}
|
||||
|
||||
func TestConfig_BackupPath(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
|
||||
assert.Contains(t, c.BackupPath(), "/storage/testdata/backup")
|
||||
}
|
||||
|
||||
func TestConfig_PIDFilename(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ func (c *Config) CreateDirectories() error {
|
|||
return createError(c.StoragePath(), err)
|
||||
}
|
||||
|
||||
if c.BackupPath() == "" {
|
||||
return notFoundError("backup")
|
||||
} else if err := os.MkdirAll(c.BackupPath(), os.ModePerm); err != nil {
|
||||
return createError(c.BackupPath(), err)
|
||||
}
|
||||
|
||||
if c.OriginalsPath() == "" {
|
||||
return notFoundError("originals")
|
||||
} else if err := os.MkdirAll(c.OriginalsPath(), os.ModePerm); err != nil {
|
||||
|
@ -137,7 +143,7 @@ func (c *Config) ConfigFile() string {
|
|||
return c.params.ConfigFile
|
||||
}
|
||||
|
||||
// ProConfigFile returns the photoprism.pro api config file name.
|
||||
// ProConfigFile returns the backend api config file name.
|
||||
func (c *Config) ProConfigFile() string {
|
||||
return filepath.Join(c.SettingsPath(), "pro.yml")
|
||||
}
|
||||
|
@ -296,6 +302,15 @@ func (c *Config) StoragePath() string {
|
|||
return fs.Abs(c.params.StoragePath)
|
||||
}
|
||||
|
||||
// BackupPath returns the backup storage path.
|
||||
func (c *Config) BackupPath() string {
|
||||
if fs.PathExists(c.params.BackupPath) {
|
||||
return fs.Abs(c.params.BackupPath)
|
||||
}
|
||||
|
||||
return filepath.Join(c.StoragePath(), "backup")
|
||||
}
|
||||
|
||||
// AssetsPath returns the path to static assets.
|
||||
func (c *Config) AssetsPath() string {
|
||||
if c.params.AssetsPath == "" {
|
||||
|
|
|
@ -123,9 +123,14 @@ var GlobalFlags = []cli.Flag{
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-path",
|
||||
Usage: "storage `PATH` for generated files like cache and index",
|
||||
Usage: "storage `PATH` for cache, database and sidecar files",
|
||||
EnvVar: "PHOTOPRISM_STORAGE_PATH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "backup-path",
|
||||
Usage: "backup storage `PATH`",
|
||||
EnvVar: "PHOTOPRISM_BACKUP_PATH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "import-path",
|
||||
Usage: "optional import `PATH` for copying files to originals",
|
||||
|
|
|
@ -49,6 +49,7 @@ type Params struct {
|
|||
LogLevel string `yaml:"log-level" flag:"log-level"`
|
||||
AssetsPath string `yaml:"assets-path" flag:"assets-path"`
|
||||
StoragePath string `yaml:"storage-path" flag:"storage-path"`
|
||||
BackupPath string `yaml:"backup-path" flag:"backup-path"`
|
||||
ImportPath string `yaml:"import-path" flag:"import-path"`
|
||||
OriginalsPath string `yaml:"originals-path" flag:"originals-path"`
|
||||
OriginalsLimit int64 `yaml:"originals-limit" flag:"originals-limit"`
|
||||
|
@ -120,6 +121,7 @@ func NewParams(ctx *cli.Context) *Params {
|
|||
func (c *Params) expandFilenames() {
|
||||
c.SettingsPath = fs.Abs(c.SettingsPath)
|
||||
c.StoragePath = fs.Abs(c.StoragePath)
|
||||
c.BackupPath = fs.Abs(c.BackupPath)
|
||||
c.AssetsPath = fs.Abs(c.AssetsPath)
|
||||
c.CachePath = fs.Abs(c.CachePath)
|
||||
c.OriginalsPath = fs.Abs(c.OriginalsPath)
|
||||
|
|
|
@ -156,6 +156,7 @@ func CliTestContext() *cli.Context {
|
|||
globalSet := flag.NewFlagSet("test", 0)
|
||||
globalSet.Bool("debug", false, "doc")
|
||||
globalSet.String("storage-path", config.StoragePath, "doc")
|
||||
globalSet.String("backup-path", config.StoragePath, "doc")
|
||||
globalSet.String("sidecar-path", config.SidecarPath, "doc")
|
||||
globalSet.String("config-file", config.ConfigFile, "doc")
|
||||
globalSet.String("assets-path", config.AssetsPath, "doc")
|
||||
|
@ -173,6 +174,7 @@ func CliTestContext() *cli.Context {
|
|||
c := cli.NewContext(app, globalSet, nil)
|
||||
|
||||
LogError(c.Set("storage-path", config.StoragePath))
|
||||
LogError(c.Set("backup-path", config.BackupPath))
|
||||
LogError(c.Set("sidecar-path", config.SidecarPath))
|
||||
LogError(c.Set("config-file", config.ConfigFile))
|
||||
LogError(c.Set("assets-path", config.AssetsPath))
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Config represents photoprism.pro api credentials for maps & geodata.
|
||||
// Config represents backend api credentials for maps & geodata.
|
||||
type Config struct {
|
||||
Key string `json:"key" yaml:"key"`
|
||||
Secret string `json:"secret" yaml:"secret"`
|
||||
|
@ -33,7 +33,7 @@ type Config struct {
|
|||
FileName string `json:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// NewConfig creates a new photoprism.pro api credentials instance.
|
||||
// NewConfig creates a new backend api credentials instance.
|
||||
func NewConfig(version string, fileName string) *Config {
|
||||
return &Config{
|
||||
Key: "",
|
||||
|
@ -54,13 +54,13 @@ func (c *Config) MapKey() string {
|
|||
}
|
||||
}
|
||||
|
||||
// Propagate updates photoprism.pro api credentials in other packages.
|
||||
// Propagate updates backend api credentials in other packages.
|
||||
func (c *Config) Propagate() {
|
||||
places.Key = c.Key
|
||||
places.Secret = c.Secret
|
||||
}
|
||||
|
||||
// Sanitize verifies and sanitizes photoprism.pro api credentials.
|
||||
// Sanitize verifies and sanitizes backend api credentials.
|
||||
func (c *Config) Sanitize() {
|
||||
c.Key = strings.ToLower(c.Key)
|
||||
|
||||
|
@ -74,7 +74,7 @@ func (c *Config) Sanitize() {
|
|||
}
|
||||
}
|
||||
|
||||
// DecodeSession decodes photoprism.pro api session data.
|
||||
// DecodeSession decodes backend api session data.
|
||||
func (c *Config) DecodeSession() (Session, error) {
|
||||
c.Sanitize()
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (c *Config) DecodeSession() (Session, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
// Refresh updates photoprism.pro api credentials.
|
||||
// Refresh updates backend api credentials.
|
||||
func (c *Config) Refresh() (err error) {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
@ -174,7 +174,7 @@ func (c *Config) Refresh() (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Load photoprism.pro api credentials from a YAML file.
|
||||
// Load backend api credentials from a YAML file.
|
||||
func (c *Config) Load() error {
|
||||
if !fs.FileExists(c.FileName) {
|
||||
return fmt.Errorf("settings file not found: %s", txt.Quote(c.FileName))
|
||||
|
@ -205,7 +205,7 @@ func (c *Config) Load() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Save photoprism.pro api credentials to a YAML file.
|
||||
// Save backend api credentials to a YAML file.
|
||||
func (c *Config) Save() error {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
|
||||
Package pro contains photoprism.pro api config & clients.
|
||||
Package pro contains backend api config & clients.
|
||||
|
||||
Copyright (c) 2018 - 2020 Michael Mayer <hello@photoprism.org>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
var ApiURL = "https://api.photoprism.app/v1/hello"
|
||||
|
||||
// photoprism.pro api credentials request incl basic runtime specs for statistical evaluation.
|
||||
// backend api credentials request incl basic runtime specs for statistical evaluation.
|
||||
type Request struct {
|
||||
ClientVersion string `json:"ClientVersion"`
|
||||
ClientOS string `json:"ClientOS"`
|
||||
|
|
|
@ -2,7 +2,7 @@ package pro
|
|||
|
||||
import "time"
|
||||
|
||||
// Session represents photoprism.pro api session data.
|
||||
// Session represents backend api session data.
|
||||
type Session struct {
|
||||
MapKey string
|
||||
ExpiresAt string
|
||||
|
|
|
@ -61,6 +61,10 @@ func FileExists(fileName string) bool {
|
|||
|
||||
// PathExists returns true if path exists and is a directory or symlink.
|
||||
func PathExists(path string) bool {
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
info, err := os.Stat(path)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -8,13 +8,13 @@ MODEL_PATH="assets/nasnet"
|
|||
MODEL_ZIP="/tmp/photoprism/nasnet.zip"
|
||||
MODEL_HASH="f18b801354e95cade497b4f12e8d2537d04c04f6 $MODEL_ZIP"
|
||||
MODEL_VERSION="$MODEL_PATH/version.txt"
|
||||
MODEL_BACKUP="storage/backups/nasnet-$TODAY"
|
||||
MODEL_BACKUP="storage/backup/nasnet-$TODAY"
|
||||
|
||||
echo "Installing $MODEL_NAME model for TensorFlow..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p /tmp/photoprism
|
||||
mkdir -p storage/backups
|
||||
mkdir -p storage/backup
|
||||
|
||||
# Check for update
|
||||
if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then
|
||||
|
|
|
@ -8,13 +8,13 @@ MODEL_PATH="assets/nsfw"
|
|||
MODEL_ZIP="/tmp/photoprism/nsfw.zip"
|
||||
MODEL_HASH="2e03ad3c6aec27c270c650d0574ff2a6291d992b $MODEL_ZIP"
|
||||
MODEL_VERSION="$MODEL_PATH/version.txt"
|
||||
MODEL_BACKUP="storage/backups/nsfw-$TODAY"
|
||||
MODEL_BACKUP="storage/backup/nsfw-$TODAY"
|
||||
|
||||
echo "Installing $MODEL_NAME model for TensorFlow..."
|
||||
|
||||
# Create directories
|
||||
mkdir -p /tmp/photoprism
|
||||
mkdir -p storage/backups
|
||||
mkdir -p storage/backup
|
||||
|
||||
# Check for update
|
||||
if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then
|
||||
|
|
Loading…
Reference in a new issue