Running a custom backup script with a python dependency

Hi,

My goal is to run a nightly job that invokes a Python script installed from a package (flickrbackup). This will download photos and store them in a folder.

On Core I had a jail where I installed this package manually, mounted a data set for the output files, and set up a local cron job inside the jail.

What is the best way to do this on Scale? I could create a docker image for the package and run it via cron on the TrueNAS host but I am not sure how to then install it (it’s not an app really and won’t need to be running in kubernetes).

Equally I could create an image with its own cron, parameters to configure timing and assume it is long running. That feels fiddly but maybe there is a base image to start from?

Are there examples I could copy from? I saw a post on the old forum that ran some obscene kubectl command to invoke a script in a running container with an unstable name but that felt wrong.

Note: my experience with kubernetes is minimal and whilst I understand docker better it’s still something I have to look up each time I use it. :slight_smile:

Which scale version are you running?

If it is more than a simple script and you are running 35.04 then just create an incus instance and install it there

Hi,

25.04.0 (downloaded yesterday).

I’m afraid I haven’t yet heard of Incus, but I gather it’s a VM? My NAS runs on ancient hardware (Microserver Gen 8, Celeron G1610T, 16GB RAM), but I think it might be able to run in a container which would help I imagine.

It’s not a complicated thing - just a single command to run each night that needs access to a folder structure.

Martin

An instance can be either a container or a vm. I should have clarified that. I apologize.

Just create a container instance and install whatever you want just like a jail :slightly_smiling_face:

An incus container can be compared to a jail on core. You can manually choose a distribution (debian, ubuntu etc) and then install any additional software inside the container via package manager ( apt for debian or ubuntu)

Thank you @MSameer and @LarsR - I got ubuntu running in an incus container and have installed the script there. However, I’m struggling with file permissions. I’ve mounted the destination data set (as a “disk” in the UI) on /data but every file there is owned by nobody:nogroup instead of the host system user.

I created a user with the same name and id inside the container but it still appears as nobody. How can I match the user ids so that when my backup script runs, it’ll write as the intended user?

by default truenas only maps user 568 to the container. Try giving user 568 “apps” permissions to the dataset you’ve mapped inside the container.

Edit:
You can add users to the list of mapped users.
In the instances gui menu on the top right corner click on configuration and then map user/group ids

1 Like