Cron – Autothesqlbackup – dumped files have wrong permissions

chmodcronroot

This question has been askewd here. But it was not answered.

I just got a 3rd server and on all 3 servers I use Automysqlbackup script to create MySQL backups. I do it with cronjob:

52 04 * * * /home/backups/backup.sh >/dev/null 2>&1

Dumped and gzipped files of 2 first servers have permissions 644 and I can download them. The new 3rd server creates files with permissions 640 and I can not download them. I have checked the script and it looks that the script does not set/changepermissions of created files. If I login as root and manually create a file in backup folder it has permission 644 as it should be.

All folders/files of Automysqlbackup script have the same permissions on all 3 servers. Backup folders with dumped files have the same permissions on all 3 servers.

My questions.

  1. Does anyone knows why my 3rd server creates backup files with permission 640 and not 644? How to fix it?
  2. If there is no fix for it, anyone who using Automysqlbackup script and can me advise what do I need to change in the script to chmod created files 644? Sorry, I know Php but not bash scripts.

Best Answer

What you might be able to do in your case is to change your backup script so that the line:

 umask 022 

appears near the top BEFORE any file is created. This will generate files with a default permissions of 755 or 644 (depending if it is a file or directory). However, this default can be overridden by any of the applications running within the script.