Copying files between accounts
AnsweredHi,
I'm trying to backup files between two accounts using php. The files live outside the root and won't copy. I can copy files within the account without problem.
This works.
copy('/home/xxxxxx/somedirectory/a.zip', '/home/xxxxxx/diffdirectory/a.zip,');
This doesn't
copy('/home/xxxxxx/somedirectory/a.zip', '/home/yyyyyy/diffdirectory/a.zip,');
Any idea how to enable copying between accounts?
Thanks
-
Hey there! There is no way to do this as a cPanel user due to the permissions on the server. You would have to be the root user in order to perform this action.
0 -
Thanks for that. I am the WHM root user. How do I go about enabling this code as the root user?
0 -
You would need to call that PHP script as root, so a cron job under the root user would work.
0 -
Right. How do I call the script as root?
In account xxxxx I have
<-- ?php
copy('/home/xxxxx/somedirectory/a.zip', '/home/yyyyyy/diffdirectory/a.zip,');
-->
What do I need to modify?
I can log into cpanel from whm as the root user but I'm not sure how that would help.
Thanks0 -
The file likely wouldn't be stored under the account. It would be best to place this in /root or somewhere else on the server where it isn't limited to one account.
Then you would create the cron with a command similar to this:
x x x x x /usr/local/bin/php /full/path/to/your/file.php
https://support.cpanel.net/hc/en-us/articles/360051846373-Create-a-Root-user-cron-job
0 -
I had tried creating zipper.sh and placed it in the root but running a cron job to read it from the account didn't work. It didn't see it. Looking in WHM the only reference to running a cron job doesn't allow for creating a cron job. Just Command: upcp and backup.
0 -
You wouldn't be able to create the cron job as the user. Everything has to be done as root. You'll have to use the steps I linked above on the command line in order to add a new cron.
0 -
Thanks. I'm able to add the command in terminal as per those instructions but it doesn't get saved when applying this instruction
If the editor is "vi," or similar:
- Press ESC
- Type ":wq"
- Press enter
The cursor moves back a space when I escape, typing .wq creates a copy of the command and appends it to the command. Which I have to then delete. Ctrl+C doesn't save either.
After typing the command how do I save it. Thanks
0 -
You want a colon, :, not a period before the wq.
0 -
Ahh, thanks. My bad eyes :) That worked
0 -
Glad to hear it!
0
Please sign in to leave a comment.
Comments
11 comments