2

I'm using BackupNinja on Raspbian Jessie Lite to create a scheduled backup of my SD. The backup job is configured as a simple TAR file backup.

The default permissions on the generated backup files are:

-rw- --- --- root:root

I want to change the default permissions and owner of the .tar files generated after the backup process ends. Is there an option for BackupNinja to do that, something like a "File owner" option that is set by default to root, or can I configure it on the job?

Otherwise do I need to make my own script that uses chown and chmod?

1

I don't know anything about BackupNinja but if it (like most backup programs) can write to stdout then you can do something like this:

echo foo | su -g users nobody bash -c 'umask 177; cat >/tmp/newfile'
ls -l /tmp/newfile
-rw------- 1 nobody users 4  4. Feb 09:39 /tmp/newfile
  • I guess there was an option on BakupNinja to set the owner of the backup file... I'll try with your script. – Cheshire Cat Feb 4 '16 at 9:12
0

The owner of the files that are generated by a process are the same as the owner of the process itself. When your backup tool runs as root than the owner of the backup-tar will be root.

The solution to the problem should be, that you run the backup process as user and not as root. I guess you use something like a cron job to do your backup. So Refer to the following link to run a cron job as specific user:

[https://superuser.com/questions/170866/how-to-run-a-cron-job-as-a-specific-user][1]

I hope this was helpful.

  • A rather fragwürdig suggestion as the backup process then probably could not ready much of what it's supposed to store any more. You can do this by adding Linux capabilities to the user process (thus making it root for file system access) but that is probably not the easier approach. – Hauke Laging Feb 4 '16 at 8:44
  • BTW: Berlin's Linux learners are invited to BeLUG's events: belug.de/aktivitaeten-kalender.html – Hauke Laging Feb 4 '16 at 8:45
  • @fragwürdig BackupNinja has a kind of wizard that helps you create and manage multiple backup jobs. Any job can be different: rdiff, tar, and so on. The process runs as root just because it is an RPi. Creating a specific user for backup that has some root privileges wasn't so convenient. – Cheshire Cat Feb 4 '16 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.