remove last remnants of Paths, now only 1 directory per path AND created a new db-container subdir that takes the latest postgres image and adds a crontab / uses cron to run a bkup_users.sh script that dumps the person, refimg and linkage table so that if we ever blow the DB away, we dont lose the users
This commit is contained in:
6
TODO
6
TODO
@@ -1,9 +1,5 @@
|
|||||||
## GENERAL
|
## GENERAL
|
||||||
* remove multiple Paths from SettingsIPath, etc.
|
* change the rotation code to use that jpeg util to reduce/remove compression loss?
|
||||||
|
|
||||||
* put a 'job' in to dump those users out to the filesystem so when we rebuild the padb docker container, we dont have to re-add the users/refimgs, etc.
|
|
||||||
|
|
||||||
* should I change the rotation code to use that jpeg util to reduce/remove compression loss?
|
|
||||||
|
|
||||||
* should allow context menu from View thumbs (particularly useful on search) to show other files around this one by date (maybe that folder or something?)
|
* should allow context menu from View thumbs (particularly useful on search) to show other files around this one by date (maybe that folder or something?)
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ RUN truncate -s0 /tmp/preseed.cfg && \
|
|||||||
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
RUN apt-get update && apt-get -y install cron
|
RUN apt-get update && apt-get -y install cron
|
||||||
COPY crontab /etc/crontab
|
COPY crontab /etc/crontab
|
||||||
|
COPY bkup_users.sh /tmp/
|
||||||
EXPOSE 5432
|
EXPOSE 5432
|
||||||
CMD ["sh", "-c", "cron ; /usr/local/bin/docker-entrypoint.sh postgres"]
|
CMD ["sh", "-c", "cron ; /usr/local/bin/docker-entrypoint.sh postgres"]
|
||||||
|
|||||||
7
db-container/bkup_users.sh
Executable file
7
db-container/bkup_users.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
pg_dump -a --user=pa --table=person --table=refimg --table=person_refimg_link > /tmp/new_users.sql
|
||||||
|
tmp=`diff -q /docker-entrypoint-initdb.d/users.sql /tmp/new_users.sql`
|
||||||
|
if (( $? !=0 && $(stat -c%s "/tmp/new_users.sql") > 200000 )) ; then
|
||||||
|
cp -f /tmp/new_users.sql /docker-entrypoint-initdb.d/users.sql
|
||||||
|
fi
|
||||||
@@ -1 +1 @@
|
|||||||
* * * * * root pg_dump -a --user=pa --table=person --table=refimg --table=person_refimg_link > /tmp/new_users.sql
|
* * * * * root /tmp/bkup_users.sh
|
||||||
|
|||||||
15
files.py
15
files.py
@@ -371,13 +371,11 @@ def GetEntries( OPT ):
|
|||||||
|
|
||||||
paths = []
|
paths = []
|
||||||
if OPT.path_type == 'Storage':
|
if OPT.path_type == 'Storage':
|
||||||
paths = SettingsSPath()
|
path = SettingsSPath()
|
||||||
elif OPT.path_type == 'Import':
|
elif OPT.path_type == 'Import':
|
||||||
paths = SettingsIPath()
|
path = SettingsIPath()
|
||||||
elif OPT.path_type == 'Bin':
|
elif OPT.path_type == 'Bin':
|
||||||
paths.append(SettingsRBPath())
|
path = SettingsRBPath()
|
||||||
|
|
||||||
num_paths = len(paths)
|
|
||||||
|
|
||||||
num_entries=0
|
num_entries=0
|
||||||
path_cnt=1
|
path_cnt=1
|
||||||
@@ -388,9 +386,6 @@ def GetEntries( OPT ):
|
|||||||
update_last_eid = True
|
update_last_eid = True
|
||||||
else:
|
else:
|
||||||
update_last_eid = False
|
update_last_eid = False
|
||||||
for path in paths:
|
|
||||||
if not os.path.exists(path):
|
|
||||||
continue
|
|
||||||
prefix = SymlinkName(OPT.path_type,path,path+'/')
|
prefix = SymlinkName(OPT.path_type,path,path+'/')
|
||||||
if OPT.folders:
|
if OPT.folders:
|
||||||
tmp_ents, tmp_num_ents = GetEntriesInFolderView( OPT, prefix )
|
tmp_ents, tmp_num_ents = GetEntriesInFolderView( OPT, prefix )
|
||||||
@@ -398,10 +393,6 @@ def GetEntries( OPT ):
|
|||||||
tmp_ents, tmp_num_ents = GetEntriesInFlatView( OPT, prefix )
|
tmp_ents, tmp_num_ents = GetEntriesInFlatView( OPT, prefix )
|
||||||
entries += tmp_ents
|
entries += tmp_ents
|
||||||
num_entries += tmp_num_ents
|
num_entries += tmp_num_ents
|
||||||
# if we have another path, keep adding num_etnries, and last_eid is the last path, not this one, so reset to 0
|
|
||||||
if update_last_eid and path_cnt < num_paths:
|
|
||||||
OPT.last_eid=0
|
|
||||||
path_cnt += 1
|
|
||||||
|
|
||||||
if update_last_eid:
|
if update_last_eid:
|
||||||
# find pref... via path_type if we are here
|
# find pref... via path_type if we are here
|
||||||
|
|||||||
@@ -2245,7 +2245,10 @@ def ReloadMetadata(job):
|
|||||||
match=re.search( '(\d+)_([^_]+)', fname )
|
match=re.search( '(\d+)_([^_]+)', fname )
|
||||||
face_id=match.group(1)
|
face_id=match.group(1)
|
||||||
person_tag=match.group(2)
|
person_tag=match.group(2)
|
||||||
p = session.query(Person).filter(Person.tag==person_tag).one()
|
p = session.query(Person).filter(Person.tag==person_tag).first()
|
||||||
|
if not p:
|
||||||
|
print( f"There is a metadata override on the file system for person: {person_tag} - but they are no longer in the DB - skip" )
|
||||||
|
continue
|
||||||
face_data=GetFaceInMetadata(fname)
|
face_data=GetFaceInMetadata(fname)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print( f"Found metadata showing Override match for person: {person_tag}" )
|
print( f"Found metadata showing Override match for person: {person_tag}" )
|
||||||
|
|||||||
18
settings.py
18
settings.py
@@ -161,12 +161,11 @@ def SettingsSPath():
|
|||||||
if settings == None:
|
if settings == None:
|
||||||
print("Cannot create file data with no settings / storage path is missing")
|
print("Cannot create file data with no settings / storage path is missing")
|
||||||
return
|
return
|
||||||
for p in settings.storage_path.split("#"):
|
if settings.storage_path[0] == '/':
|
||||||
if p[0] == '/':
|
path=settings.storage_path
|
||||||
paths.append(p)
|
|
||||||
else:
|
else:
|
||||||
paths.append(settings.base_path+p)
|
path=settings.base_path+settings.storage_path
|
||||||
return paths
|
return path
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# SettingsIPath(): return modified array of paths (take each path in
|
# SettingsIPath(): return modified array of paths (take each path in
|
||||||
@@ -178,12 +177,11 @@ def SettingsIPath():
|
|||||||
if settings == None:
|
if settings == None:
|
||||||
print ("Cannot create file data with no settings / import path is missing")
|
print ("Cannot create file data with no settings / import path is missing")
|
||||||
return
|
return
|
||||||
for p in settings.import_path.split("#"):
|
if settings.import_path[0] == '/':
|
||||||
if p[0] == '/':
|
path=settings.import_path
|
||||||
paths.append(p)
|
|
||||||
else:
|
else:
|
||||||
paths.append(settings.base_path+p)
|
path=settings.base_path+settings.import_path
|
||||||
return paths
|
return path
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# SettingsMPath(): return path to actual metadata path from settings
|
# SettingsMPath(): return path to actual metadata path from settings
|
||||||
|
|||||||
Reference in New Issue
Block a user