the-paperless-project / paperless

Scan, index, and archive all of your paper documents
GNU General Public License v3.0
7.85k stars 498 forks source link

How to export periodically? #584

Open mikkelnl opened 4 years ago

mikkelnl commented 4 years ago

Hi!

I'm running Paperless in a docker container on my Synology NAS, which seems to be running fine.

I would like to export alle the documents every night with the 'export' option. When I enter the container via the terminal option in Synology Docker GUI, I can run this command just fine:

/usr/src/paperless/src/manage.py document_exporter /export

So I figured, I'd enter this command in the crontab in this container, via:

crontab -e

There I added this line:

50 23 * * * /usr/src/paperless/src/manage.py document_exporter /export

But it doesn't seem to be executed at all. I'm not very familiar with linux, crontab, etc, so I might be missing something here ;-)

Anyway, does anybody perhaps know a way to automatically export documents periodically?

sceiler commented 4 years ago

Did you restart the cron service?

mikkelnl commented 4 years ago

Did you restart the cron service?

I tried rebooting the container, didn't help... I didn't know cron needs to restart, I thought crontab -e would do that itself... might be wrong though :)

sceiler commented 4 years ago

I have a cron job for something else on my Synology and I have just restarted cron after making changes. I never checked if it would work without it but my cron job is doing what I expect so try restarting your cron job. Also make sure that your cron file is not on a memory-only partition and gets deleted after a restart of your NAS.

mikkelnl commented 4 years ago

I have a cron job for something else on my Synology and I have just restarted cron after making changes. I never checked if it would work without it but my cron job is doing what I expect so try restarting your cron job. Also make sure that your cron file is not on a memory-only partition and gets deleted after a restart of your NAS.

A cronjob run by DSM is fine, got them running for other stuff too.

But as far as I know, if I want Paperless to export documents, I have to enter the container, open the Terminal tab in the Synology Docker GIU, start a terminal window, and then enter this command in this terminal window:

/usr/src/paperless/src/manage.py document_exporter /export

So if I'm correct, this can't be done via a DSM cron task, since the command is given inside a terminal window for the container.

Therefor, I tried crontab -e in the container - so not the cron from DSM - but that doesn't seem to work.

I'll keep trying.

My goal: export all documents inside Paperless to nice readable pdf files via the /usr/src/paperless/src/manage.py document_exporter /export command, and have this done every 24 or 48 hours.

sceiler commented 4 years ago

Ah! Sorry misunderstood you. Try this here I found on Stackoverflow:

docker exec mycontainer /bin/sh -c "./usr/src/paperless/src/manage.py document_exporter /export"

Put this line in a .sh script for example daily_export.sh. In your cron job let it execute daily_export.sh. I haven't tried this so be careful.

mikkelnl commented 4 years ago

Ah! Sorry misunderstood you. Try this here I found on Stackoverflow:

docker exec mycontainer /bin/sh -c "./usr/src/paperless/src/manage.py document_exporter /export"

Put this line in a .sh script for example daily_export.sh. In your cron job let it execute daily_export.sh. I haven't tried this so be careful.

Awesome, wonder why I didn't think of such a command :D Your cmd line almost works, I had to remove the . in the path, but this should work... going to set the .sh script in the scheduler... thanks again.