3

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?

2 Answers 2

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
1
  • I guess there was an option on BakupNinja to set the owner of the backup file... I'll try with your script. Feb 4, 2016 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.

3
  • 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. Feb 4, 2016 at 8:44
  • BTW: Berlin's Linux learners are invited to BeLUG's events: belug.de/aktivitaeten-kalender.html Feb 4, 2016 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. Feb 4, 2016 at 9:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .