PetaByet / cdp

Simple & Open Source Server Backups
https://cdp.me
GNU General Public License v2.0
122 stars 39 forks source link

"Backup Now" fail as fopen got permission denied #4

Closed yywudi closed 10 years ago

yywudi commented 10 years ago

after add backup jobs, run as root manually with command is OK, but click the Backup Now in the job, always fail, seems permission issue when create backup .tar.gz file under files folder. I've already chmod 777 files, and chown -R www-data:www-data to the cdp folder, also enable the fopen in php.ini as below. allow_url_fopen = On allow_url_include = On

but always failed, any suggestion how to configure the permission?

Backup task is running in the background Warning: fopen(cdpme-2014-11-12-06-47-20-4bfbb1c2f*****f5f61fb5a.tar.gz): failed to open stream: Permission denied in /var/www/****/public/cdp/phpseclib/Net/SFTP.php on line 2026

Warning: rename(cdpme-2014-11-12-06-47-20-4bfbb1c2ff5f61fb5a.tar.gz,/var/www/****/public/cdp/files/cdpme-2014-11-12-06-47-20-4bfbb1c2ff5f61fb5a.tar.gz): No such file or directory in /var/www/****/public/cdp/cron.php on line 130

Warning: filesize(): stat failed for /var/www/**_/public/cdp/files/cdpme-2014-11-12-06-47-20-4bfbb1c2f_**f5f61fb5a.tar.gz in /var/www/****/public/cdp/cron.php on line 139

yywudi commented 10 years ago

View Backups will show all the failed backup job with filesize NANb, and can't delete those content as "file not exist"

PetaByet commented 10 years ago

I pushed an update for index.php, please try it and let me know if the error still occurs. If so, please make sure php/apache get enough permission to run cron.php using shell_exec().

yywudi commented 10 years ago

update the index.php, and re-test.
still no backup file created, add one more backup log with NANb file size. I'm not sure if enable shell_exec() permission correctly, i'm using nginx & php-fpm. but there's no error just "Backup task has been started, please do not close this window".

besides, is that safe to run shell_exec() for php?

PetaByet commented 10 years ago

Please add echo to line 149, like echo shell_exec('php '.$config['path'].'/cron.php '.$_REQUEST['id']); so you can see the output.

yywudi commented 10 years ago

yep the echo for shell_exec got the same error as before: Warning: fopen(cdpme-2014-11-12-07-47-25-ac8a***_a3e6ba16.tar.gz): failed to open stream: Permission denied in /var/www/_*/public/cdp/phpseclib/Net/SFTP.php on line 2026

PetaByet commented 10 years ago

You can probably use sudo and grant the apache user root permissions.

yswery commented 10 years ago

Dont ever do that, pleaseeeeee! never ever EVER give a website escalated privileges. It will be pretty much equal to bending over in a prison shower, waiting to get raped

bradbeckett commented 10 years ago

The solution to this is: chown -R apache:apache /var/www/html/