Changing default file permission on redis dump

最后都变了- 提交于 2019-12-10 16:17:39

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/13364713/changing-default-file-permission-on-redis-dump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!