Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm an admin at a forum that uses http://www.one.com/en/ as their web hotel.
I want to make a "remote" backup of the mysql database cos that is way faster than to use
phpmyadmin, and likewise with all the web files. (The last one takes over an hour to get)
one.com's php memory_limit is 65M so when I try to run the php script I get the error:
"PHP Fatal error: Out of memory (allocated 16777216) (tried to allocate 21979956 bytes) in /customers/xxxx/httpd.www/forum/admin/backup/backup.mysql.php on line 34"
I tried to use
Code:
ini_set('memory_limit', '256M');
but with this wouldn't work.
First, is there a way to list the memory_limit with a php script?
this so I can first list it, then change it and list it again to see if my value was set or not.
Second, if the above won't work, is there a way to run the script but with a limited memory so it'll be within the limit?
Yes phpinfo() is solution to see allowed memory.
If you are on shared server, maybe you can't get 256 Mb memory, depends of the hosting.
However, I prefer to put single command in a bash script, and this in cron job. It works faster.
Command may be like this: mysqldump --user=dbUser --password=dbPassword databaseName > databaseNameBackup.sql
Don't ask php to do such a thing! Don't ask a httpd server to do such a thing!
You need a background script, unrelated to the web server, to be performing these operations.
Yes, you can of course write that script in php if you want to ... or in any other programming language that you prefer. That's your choice. It's not the language's fault, nor its limitation. (PHP is every bit as capable as any other full-featured programming language, and, like any of them, it can be used outside of a web-page context.) Rather, it is a highly inappropriate task to be being done by a web server.
Good production systems will have some kind of "batch job" processing system that is capable of farming out tasks to other computers or at least to other processes. You could, if you wish, build a web-page administrative interface to such an external system so that authorized users could start these jobs and monitor their progress.
Even though Unix/Linux does not always ship with a batch-job monitor (unlike the venerable and batch-centric IBM MVS system of yore .. which still exists, by the way .. plenty of good ones are available. You don't even need to "roll your own."
Last edited by sundialsvcs; 03-01-2012 at 08:43 AM.
@anomie: OK, thanks for the phpinfo() I'll keep that in mind.
@resolv_25: Can I really use mysqladmin in php on a server that is hosted by a company? don't you think that is locked down? and if I can, this would be run as a bach shell script from within php, right? The testing here at home is very easy since I can do whatever I like and uses SSH for this.
@sundialsvcs: This I know and while testing on my own test server I saw the php using almost 100%, just some percentage left for mysql But I didn't even think that 'resolv's' version would work, and as you see my question to him/her, I still don't
The other thing I was talking about, copying all web files. This thing takes over an hour to get "home" to my place so I tried to use ZipArchive in php for that.
The max file size of the file created, with a temporary file name though, is 128,00Mbytes and then the php stops with an "Internal Server Error"
What I wonder is, is there a way to create multiple files with smaller size instead with parameters or such?
or do I have to do that myself and check the file size after every file added and then use ::addFile to add more if not "big" enough?
@anomie: OK, thanks for the phpinfo() I'll keep that in mind.
@resolv_25: Can I really use mysqladmin in php on a server that is hosted by a company? don't you think that is locked down? and if I can, this would be run as a bach shell script from within php, right? The testing here at home is very easy since I can do whatever I like and uses SSH for this.
There are 2 solutions, as sundialsvcs proposed, better put the script out of php.
Typically hosting allows cron jobs option. Just paste this previous code line in cron job line, and pick up the interval of executing.
Second, put this line in a bash script and put your script in a cron job. In a script you may put backups for different databases separately.
This is more simple to handle and process is automatic.
one.com won't have anything else then FTP or phpMyAdmin, so that sucks.
When I read this just recently I got furious because I had not a CLUE about this.
So now not one bit of change is gonna happen until we move this place.
one.com has no 'cpanel' and no SSH or such for the MySql-DB administration nor all the web files.
For the web files there is only FTP to download them "home" and that sure sucks.
I'm already out looking for other hosts
.....after the move I think it'll all be smooth as glass :P
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.