4

I have a cron job, which is running under a user called 'deployer' with limited access. The cron job is performing a backup of my redis database resulting in a dum /var/lib/redis/dump.rdb.

Now the cron job now tries to perform a /bin/gzip -c /var/lib/redis/dump.rdb > /home/deployer/Backup/.tmp/redis_backup/databases/Redis/dump.rdb.gz before shipping it off to S3. The problem is, that the permissions on /var/lib/redis/dump.rdb is -rw-rw----, so I get the following error:

gzip: /var/lib/redis/dump.rdb: Permission denied

So my question is, I'm not interested in giving my deployer user wider permissions, so I would like that dump, that is being created every time the cron job is run, to have other permissions.

How can I accomplish that the simplest way?

Niels Kristian
  • 8,661
  • 11
  • 59
  • 117

1 Answers1

3

The Redis dump file is created with a standard fopen('...',"w") call. So the access rights are actually inherited from the current umask.

Try to alter the umask in the script or the shell used to launch the Redis server, before launching the Redis server itself, by using the umask command:

$ umask 022

This command will change the mask so that new files will be created with 644 access rights (666 being the default access rights).

Didier Spezia
  • 70,911
  • 12
  • 189
  • 154