Backup error permission denied

I’m trying to get a successful backup FreePBX 14.0.13.40, Asterisk 13.32.0. I’m backing up to a WD NAS drive using Backup and Restore 10.0.10.11 using the Full Backup Template The path in the server setup is //192.168.xxx.xxx/nfs/PBX

Initializing Backup 5
Backup Lock acquired!
Running pre-backup hooks…
Adding items…
Building manifest…
Creating backup…
Storing backup…
Could not connect to server nfs://192.168.xxx.xxx/nfs/PBX:21
Whoops\Exception\ErrorException: mkdir(): Permission denied in file /var/www/html/admin/modules/backup/functions.inc/class.backup.php on line 356
Stack trace:

  1. Whoops\Exception\ErrorException->() /var/www/html/admin/modules/backup/functions.inc/class.backup.php:356
  2. mkdir() /var/www/html/admin/modules/backup/functions.inc/class.backup.php:356
  3. FreePBX\modules\Backup\Backup->store_backup() /var/www/html/admin/modules/backup/bin/backup.php:149

It appears it’s a user name/permission issue. What user name an password is FreePBX trying to use here? I even tried setting the Share user to any puplic user and allowing anonymous Read/write, but it still fails.

I’d sure feel better if I had a backup of the system somewhere.

first thing I would try is

fwconsole chown

Is there a way to then test that without doing the entire backup again? It takes a very long time before the error shows up.

Sorry I skimmed to quickly… That is your issue. You have an NFS configuration issue.

You can create a backup for 1 module just as a test

So that did let me test. It still failed. But it tested quickly. Thank you.

It still seems to be a permission thing on the NFS but how can I tell what login and password FreePBX is trying to use so I can add it to the NFS permission? Or the other way around, where do I set that on FreePBX?

As a test I set it to backup to a different NAS, an Iomega. It zips through the process but I wonder if it’s really there. From start to finish for a full system backup including all CDR and recordings took less than 2 min. Could it really have done a backup of everything that quickly?

Hi there!
Where is mounted your NFS shared folder?
I recommned you to do it under /var/spool/asterisk/ so asterisk user has permissions there.

The NAS is set up in the FreePBX GUI under the Servers tab with the hostname of nfs://192.168.xxx.xxx/nfs/PBX on Port 21. The share on the NAS is setup with Public FTP access turned on (anonymous Read/Write) with a mount point of nfs://192.168.xxx.xxxx/nfs/PBX so it should have access. I don’t know why it’s getting a permission error.

I’m afraid I don’t know how to create a mount in directory you suggest. My Linux is poor.

Try this:
mkdir -p /var/spool/asterisk/backup/nfs && chown asterisk.asterisk /var/spool/asterisk/backup/nfs
mount -t nfs your-nas-ip-here:/your-shared-folder /var/spool/asterisk/backup/nfs

Is the error because I need the entire mount point instead of just the IP? ie replace //192.168.xxx.xxx with
//192.168.xxx.xxx/nfs/PBX? Or do I need to lose the // before the IP?

mount -t nfs //192.168.xxx.xxx:/PBX /var/spool/asteri sk/backup/nfs

mount: wrong fs type, bad option, bad superblock on //192.168.xxx.xxx:/PBX,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)

   In some cases useful info is found in syslog - try
   dmesg | tail or so.

So I tried mount -t nfs://192.168.xxx.xxx/nfs/PBX /var/spool/asterisk/backup/nfs and got this error.

mount: can’t find /var/spool/asterisk/backup/nfs in /etc/fstab

Install nfs-utils first: yum install nfs-utils
After that, the command should be: mount -t nfs 192.168.xxx.xxx:/PBX /var/spool/asterisk/backup/nfs

Are you 100% sure that your “PBX” folder is on the root directory (talking about the NAS)
If that command didn’t work, try with this one, just in case PBX is inside “nfs”
Also, saw some NFS where is not the same NFS or nfs, so be sure to write the way you have it on your NAS.

After that, the command should be: mount -t nfs 192.168.xxx.xxx:/nfs/pbx /var/spool/asterisk/backup/nfs

The mount point listed in the NAS is
Mount Point: nfs://192.168.xxx.xxx/nfs/PBX
To me that looks like the PBX isn’t on the root, but is in a directory called nfs?
It appears the second command mounted. At least it didn’t generate an error so I assume it worked.
# mount -t nfs 192.168.xxx.xxx:/nfs/PBX /var/spool/asterisk/backup/nfs
# mount.nfs: access denied by server while mounting 192.168.xxx.xxx:/PBX
-bash: mount.nfs:: command not found
# mount -t nfs 192.168.xxx.xxx:/nfs/PBX /var/spool/asterisk/backup/nfs
#
However if I then try to run a short backup I still get the same Permission denied error.

Type: su asterisk && touch /var/spool/asterisk/backup/nfs/test
Do you see an error when doing that ?

]# su asterisk && touch /var/spool/asterisk/backup/nfs/test
bash-4.2$
but it doesn’t return to the # prompt.

So, you need to move to asterisk user, you should do a su asterisk
Then type “whoami” and then the touch command.
The idea is to see if you have rights to write into that directory.

bash-4.2$ whoami
asterisk
bash-4.2$ touch
touch: missing file operand
Try ‘touch --help’ for more information.
bash-4.2$

You are not typing the whole command, it’s: touch /var/spool/asterisk/backup/nfs/test
Then after that type: ls -lah /var/spool/asterisk/backup

Sorry. I warned you I wasn’t very good at this.

bash-4.2$ touch /var/spool/asterisk/backup/nfs/test
bash-4.2$ ls -lah /var/spool/asterisk/backup
total 24K
drwxrwxr-x   6 asterisk asterisk 4.0K Oct 13 08:17 .
drwxrwxr-x. 19 asterisk asterisk 4.0K Oct 13 09:07 ..
drwxrwxr-x   2 asterisk asterisk 4.0K Oct  1 00:00 Default_backup
drwxrwxrwx+  2 root     root     4.0K Oct 13 09:12 nfs
drwxrwxr-x   2 asterisk asterisk 4.0K Oct 12 16:38 PBXBackup
drwxrwxr-x   2 asterisk asterisk 4.0K Aug 23 01:53 PBXtoNAS
bash-4.2$

So that’s the reason, the nfs directory is owned by root
Run this command: chown asterisk:asterisk /var/spool/asterisk/backup/nfs
Then, run again: ls -lah /var/spool/asterisk/backup

if you see that “asterisk” is the new owner, then go and try to run the backup job again.