backup & index scripts
This commit is contained in:
parent
8143adbaf5
commit
90b36c3cd5
18
Dockerfile
18
Dockerfile
|
@ -1,33 +1,37 @@
|
|||
FROM php:7.4-apache
|
||||
LABEL maintainer="Niels Lippke<nlippke@gmx.de>"
|
||||
ENV VER 5.1.13
|
||||
ENV SEEDDMS_BASE=/var/www/seeddms
|
||||
ENV SEEDDMS_HOME=/var/www/seeddms/seeddms
|
||||
|
||||
# Update and install necessary packages
|
||||
RUN apt-get update && apt-get install --no-install-recommends gnumeric libpng-dev catdoc poppler-utils \
|
||||
id3 docx2txt tesseract-ocr tesseract-ocr-deu ocrmypdf imagemagick vim parallel dos2unix cron -y
|
||||
id3 docx2txt tesseract-ocr tesseract-ocr-deu ocrmypdf imagemagick vim parallel dos2unix cron rsync -y
|
||||
RUN docker-php-ext-install gd mysqli pdo pdo_mysql && \
|
||||
pear channel-update pear.php.net && pear install Log
|
||||
|
||||
# Get seeddms
|
||||
RUN curl -fsSL https://downloads.sourceforge.net/project/seeddms/seeddms-${VER}/seeddms-quickstart-${VER}.tar.gz | tar -xzC /var/www
|
||||
RUN mv /var/www/seeddms51x /var/www/seeddms && touch /var/www/seeddms/data/conf/ENABLE_INSTALL_TOOL
|
||||
RUN mv /var/www/seeddms51x /var/www/seeddms && mkdir /var/www/seeddms/backup && mkdir -p /var/www/seeddms/import/admin && \
|
||||
rm -rf /var/www/seeddms/conf && ln -s /var/www/seeddms/data/conf /var/www/seeddms/conf && touch /var/www/seeddms/conf/ENABLE_INSTALL_TOOL
|
||||
|
||||
# Copy settings-files
|
||||
COPY sources/php.ini /usr/local/etc/php/
|
||||
COPY sources/000-default.conf /etc/apache2/sites-available/
|
||||
COPY sources/settings.xml /var/www/seeddms/data/conf/settings.xml
|
||||
COPY sources/ocrmypdf.sh /usr/local/bin
|
||||
COPY sources/seeddms-entrypoint /usr/local/bin
|
||||
COPY sources/*.sh /usr/local/bin/
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/seeddms/ && \
|
||||
dos2unix /usr/local/bin/ocrmypdf.sh && chmod a+rx /usr/local/bin/ocrmypdf.sh && \
|
||||
dos2unix /usr/local/bin/*.sh && chmod a+rx /usr/local/bin/*.sh && \
|
||||
dos2unix /usr/local/bin/seeddms-entrypoint && chmod a+rx /usr/local/bin/seeddms-entrypoint && \
|
||||
a2enmod rewrite
|
||||
a2enmod rewrite && \
|
||||
echo "export SEEDDMS_BASE=$SEEDDMS_BASE" >> /usr/local/bin/seeddms-settings.sh && \
|
||||
echo "export SEEDDMS_HOME=$SEEDDMS_HOME" >> /usr/local/bin/seeddms-settings.sh
|
||||
|
||||
RUN cp -a /var/www/seeddms/data /var/www/seeddms/data.bak
|
||||
|
||||
# Volumes to mount
|
||||
VOLUME [ "/var/www/seeddms/data", "/var/www/seeddms/www/ext" ]
|
||||
VOLUME [ "/var/www/seeddms/backup", "/var/www/seeddms/import", "/var/www/seeddms/www/ext" ]
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/seeddms-entrypoint"]
|
||||
CMD ["apache2-foreground"]
|
50
README.md
50
README.md
|
@ -6,10 +6,56 @@ This image supports OCR processing for images and PDFs.
|
|||
|
||||
## How to run
|
||||
|
||||
`docker run --name seeddms -d -v <local>:/var/www/seeddms/data -p 8080:80 seeddms`
|
||||
`docker run --name seeddms -d -v dms-data:/var/www/seeddms/data -p 8080:80 nlippke/seeddms:5.1.13`
|
||||
|
||||
or as compose file
|
||||
|
||||
```yaml
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
dms:
|
||||
image: nlippke/seeddms:5.1.13
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- 'CRON_INDEX=0 0 * * *'
|
||||
- 'CRON_BACKUP=0 23 * * *'
|
||||
mem_limit: 2g
|
||||
volumes:
|
||||
- dms-data:/var/www/seeddms/data
|
||||
- /share/Container/container-data/seeddms/extensions:/var/www/seeddms/seeddms/ext
|
||||
- /share/Container/container-data/seeddms/backup:/var/www/seeddms/backup
|
||||
- /share/Container/container-data/seeddms/import:/var/www/seeddms/import
|
||||
logging:
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "1"
|
||||
volumes:
|
||||
dms-data:
|
||||
```
|
||||
|
||||
## Default configuration
|
||||
|
||||
The image is preconfigured. Nevertheless you're guided through the installation steps upon first start for a review.
|
||||
|
||||
1. `/var/www/seeddms/data` is the central data directory. It is not intended to be bound to a host directory. Instead use a docker volume.
|
||||
2. `/var/www/seeddms/backup` is where backups are being stored. Bind it to a host directory.
|
||||
3. `var/www/seeddms/import` is being used as drop folder. Bind it to a host directory.
|
||||
4. Optionally mount `/var/www/seeddms/seeddms/ext` to allow upload of extensions.
|
||||
|
||||
Backup and import directories should be readable/writeable by uid 33!
|
||||
|
||||
## Backup
|
||||
|
||||
Backup is done by syncing the `data` folder (partially) to the backup folder. Use environment variable `CRON_BACKUP` for automatic scheduling.
|
||||
|
||||
## Full text search
|
||||
|
||||
Indexing documents can take some time (especially on low powered NAS). Therefore indexing is done asynchronously by a job. Use `CRON_INDEX` for scheduling this job.
|
||||
|
||||
## Additional information
|
||||
|
||||
The image is base on https://github.com/ludwigprager/docker-seeddms.
|
||||
|
||||
|
||||
|
|
|
@ -11,12 +11,3 @@
|
|||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
|
||||
|
||||
<Directory "/var/www/seeddms/www/">
|
||||
DirectoryIndex index.php
|
||||
AllowOverride All
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
Allow from all
|
||||
</Directory>
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
inputpdf=$1
|
||||
tmpdir=/tmp/seed
|
||||
lockfile=$tmpdir/`basename $0`
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "args $@"
|
||||
rm -rf /tmp/seed
|
||||
|
||||
# first run?
|
||||
if [ ! -f /var/www/seeddms/data/content.db ]; then
|
||||
mkdir -p /var/www/seeddms/data
|
||||
cp -a /var/www/seeddms/data.bak/* /var/www/seeddms/data
|
||||
if [ -n "$TZ" ]; then
|
||||
echo $TZ > /etc/timezone
|
||||
fi
|
||||
|
||||
if [ ! -L "/var/www/seeddms/conf" ]; then
|
||||
rm -rf /var/www/seeddms/conf
|
||||
ln -s /var/www/seeddms/data/conf /var/www/seeddms/conf
|
||||
rm -f /etc/cron.d/seeddms
|
||||
|
||||
if [ -n "$CRON_INDEX" ]; then
|
||||
echo "$CRON_INDEX su -s /bin/bash -c /usr/local/bin/seeddms-generate-index.sh www-data" >> /etc/cron.d/seeddms
|
||||
fi
|
||||
|
||||
if [ -n "$CRON_BACKUP" ]; then
|
||||
echo "$CRON_BACKUP su -s /bin/bash -c /usr/local/bin/seeddms-generate-backup.sh www-data" >> /etc/cron.d/seeddms
|
||||
fi
|
||||
|
||||
if [ -e /etc/cron.d/seeddms ]; then
|
||||
crontab /etc/cron.d/seeddms
|
||||
fi
|
||||
|
||||
rm -f /var/run/cron*
|
||||
|
|
36
sources/seeddms-generate-backup.sh
Normal file
36
sources/seeddms-generate-backup.sh
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
. /usr/local/bin/seeddms-settings.sh
|
||||
|
||||
lockfile=$tmpdir/`basename $0`
|
||||
mkdir -p $tmpdir
|
||||
|
||||
if [ -e "$lockfile" ]; then
|
||||
log warn "indexing skipped because other backup is already running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ( set -o noclobber; echo "locked" > "$lockfile"); then
|
||||
trap 'rm -f "$lockfile"; exit $?' INT TERM KILL EXIT
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
backupdir=$SEEDDMS_BASE/backup
|
||||
|
||||
mkdir -p $backupdir/data
|
||||
|
||||
rsync -avu --delete $SEEDDMS_BASE/data/1048576 $backupdir/data
|
||||
if [ $? != 0 ]; then
|
||||
log error "Backup (rsync) failed"
|
||||
fi
|
||||
|
||||
cp -auf $SEEDDMS_BASE/data/content.db $backupdir/data
|
||||
if [ $? != 0 ]; then
|
||||
log error "Backup (database) failed"
|
||||
fi
|
||||
|
||||
cp -auf $SEEDDMS_BASE/data/conf $backupdir/data
|
||||
if [ $? != 0 ]; then
|
||||
log error "Backup (config) failed"
|
||||
fi
|
25
sources/seeddms-generate-index.sh
Normal file
25
sources/seeddms-generate-index.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
. /usr/local/bin/seeddms-settings.sh
|
||||
|
||||
lockfile=$tmpdir/`basename $0`
|
||||
mkdir -p $tmpdir
|
||||
|
||||
if [ -e "$lockfile" ]; then
|
||||
log warn "indexing skipped because other indexer is already running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ( set -o noclobber; echo "locked" > "$lockfile"); then
|
||||
trap 'rm -f "$lockfile"; exit $?' INT TERM KILL EXIT
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd $SEEDDMS_HOME/utils > /dev/null
|
||||
|
||||
/usr/local/bin/php $SEEDDMS_HOME/utils/indexer.php --config $SEEDDMS_BASE/conf/settings.xml > /dev/null
|
||||
|
||||
popd > /dev/null
|
10
sources/seeddms-settings.sh
Normal file
10
sources/seeddms-settings.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
tmpdir=/tmp/seed
|
||||
logfile=$SEEDDMS_BASE/data/log/`date +%Y%m%d`.log
|
||||
|
||||
function log() {
|
||||
printf "%s [%s] -- (localhost) %s\n" "`date +"%b %d %H:%M:%S"`" $1 "$2" >> $logfile
|
||||
}
|
||||
|
||||
export PATH=$PATH:/usr/local/bin
|
|
@ -52,7 +52,7 @@
|
|||
- cacheDir: where the preview images are saved
|
||||
- backupDir: where the backups are saved
|
||||
-->
|
||||
<server rootDir="/var/www/seeddms/seeddms-5.1.13/" httpRoot="/" contentDir="/var/www/seeddms/data/" stagingDir="/var/www/seeddms/data/staging/" luceneDir="/var/www/seeddms/data/lucene/" logFileEnable="true" logFileRotation="d" enableLargeFileUpload="false" partitionSize="2000000" cacheDir="/var/www/seeddms/data/cache/" dropFolderDir="" backupDir="/var/www/seeddms/data/backup/" checkOutDir="" createCheckOutDir="false" repositoryUrl="https://repository.seeddms.org/dd278323b03fd2aa5510b8fa9addf5ea/" maxUploadSize="" enableXsendfile="false">
|
||||
<server rootDir="/var/www/seeddms/seeddms/" httpRoot="/" contentDir="/var/www/seeddms/data/" stagingDir="/var/www/seeddms/data/staging/" luceneDir="/var/www/seeddms/data/lucene/" logFileEnable="true" logFileRotation="d" enableLargeFileUpload="false" partitionSize="2000000" cacheDir="/var/www/seeddms/data/cache/" dropFolderDir="/var/www/seeddms/import/" backupDir="/var/www/seeddms/backup/" checkOutDir="" createCheckOutDir="false" repositoryUrl="https://repository.seeddms.org/dd278323b03fd2aa5510b8fa9addf5ea/" maxUploadSize="" enableXsendfile="false">
|
||||
</server>
|
||||
|
||||
<!-- enableGuestLogin: If you want anybody to login as guest, set the following line to true
|
||||
|
|
Loading…
Reference in New Issue
Block a user