Re: Database backups initiated from Tomcat
Thanks to ALL who contributed to helping me with this! - Original Message - From: Tom K [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 9:54 PM Subject: RE: Database backups initiated from Tomcat But ?? can't you do something like this public static final void openFileAndExecuteAssociatedApplication(String fullPathAndFileName){ try { Process p = Runtime.getRuntime().exec(cmd /c start +fullPathAndFileName); p.waitFor(); } catch (Throwable ex) { ex.printStackTrace(); } } I do agree that some of this Runtime stuff is dangerous. I'm just trying to help, but I don't want to waste time, so this is my last post regarding this topic. If anyone has a proven solution please share and leave the corrections to God! Tom Kochanowicz -Original Message- From: Ben Souther [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 3:37 PM To: Tomcat Users List Subject: Re: Database backups initiated from Tomcat On Wednesday 19 May 2004 04:22 pm, Tom K wrote: I'm not sure either, but you could try it in a sync block and see if it works and let us know ;-) Yoav Shapira answered that. (getRuntime().exec is non-blocking) Read his reply for the details. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
Frank, Not having done this myself (yet), There are a few options that come to mind. 1. Set up a backup database (unless you plan to store it in the same one). Read the metadata for the table you wish to copy, create a backup table, and then do a select * and write the result set into the new table. 2. Call the script from a servlet. Sorry it has been a while since I have done a call and thus don't remember the syntax. 3. If all you need is to preserve a copy that will not be accessed, then you could block access to the table and do a file copy of the table. Sorry that I could not be of more help on item 2. Doug www.parsonstechnical.com - Original Message - From: Frank Burns [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 9:04 AM Subject: Database backups initiated from Tomcat Hi, I have an urgent requirement where I have to initiate a database backup (of three mySQL tables) prior to performing an upload and update of the database. The preferred method of backing up is to use the mysqldump script. Can anyone: 1) tell me whether this is possible -- i.e., running the mysqldump script from a servlet 2) give me any clues/details on the best way to do this? Thanks, Frank. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database backups initiated from Tomcat
What operating system are you using? It is possible to call System (and database) commands within java to execute the mysqldump script. For example for basically any operating system you can execute a Runtime.getRuntime().exec(String cmdline) Tom Kochanowicz -Original Message- From: Frank Burns [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 8:05 AM To: Tomcat Users List Subject: Database backups initiated from Tomcat Hi, I have an urgent requirement where I have to initiate a database backup (of three mySQL tables) prior to performing an upload and update of the database. The preferred method of backing up is to use the mysqldump script. Can anyone: 1) tell me whether this is possible -- i.e., running the mysqldump script from a servlet 2) give me any clues/details on the best way to do this? Thanks, Frank. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
On Wed, May 19, 2004 at 02:04:33PM +0100, Frank Burns wrote: : I have an urgent requirement where I have to initiate a database backup (of : three mySQL tables) prior to performing an upload and update of the : database. How is the update/upload being done? commandline/mysql session, within the servlet itself, etc? You could put the backup at the head of that procedure. : 1) tell me whether this is possible -- i.e., running the mysqldump script : from a servlet The one way that comes to mind is Runtime.exec(), but that may cause memory issues since (under Unix-like OSs) it calls fork(). If the container has been allocated a lot of memory, well... : 2) give me any clues/details on the best way to do this? If this *must* be done within a servlet, I don't see many options other than Runtime.exec()... -QM ps- please create a new message when posting to the list. Replying to an old (unrelated) message causes hell on thread-aware mailers, even if you change the subject. Thanks. -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
Hi QM, The upload is being done within the servlet itself. So I would, as you suggest, put the backup at the head of that. The OS is linux, and I note your comment about the potential memory issues. Can you think of any other issues with running Runtime.getRuntime().exec(String cmdline) from within a Servlet -- for example, whether Tomcat has privileges to access the script, etc.? I'm just trying fathom, as quickly as possible, whether there are any show stoppers in using this solution. Thanks, Frank. - Original Message - From: QM [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 2:52 PM Subject: Re: Database backups initiated from Tomcat On Wed, May 19, 2004 at 02:04:33PM +0100, Frank Burns wrote: : I have an urgent requirement where I have to initiate a database backup (of : three mySQL tables) prior to performing an upload and update of the : database. How is the update/upload being done? commandline/mysql session, within the servlet itself, etc? You could put the backup at the head of that procedure. : 1) tell me whether this is possible -- i.e., running the mysqldump script : from a servlet The one way that comes to mind is Runtime.exec(), but that may cause memory issues since (under Unix-like OSs) it calls fork(). If the container has been allocated a lot of memory, well... : 2) give me any clues/details on the best way to do this? If this *must* be done within a servlet, I don't see many options other than Runtime.exec()... -QM ps- please create a new message when posting to the list. Replying to an old (unrelated) message causes hell on thread-aware mailers, even if you change the subject. Thanks. -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
Thanks Doug. - Original Message - From: Parsons Technical Services [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 2:31 PM Subject: Re: Database backups initiated from Tomcat Frank, Not having done this myself (yet), There are a few options that come to mind. 1. Set up a backup database (unless you plan to store it in the same one). Read the metadata for the table you wish to copy, create a backup table, and then do a select * and write the result set into the new table. 2. Call the script from a servlet. Sorry it has been a while since I have done a call and thus don't remember the syntax. 3. If all you need is to preserve a copy that will not be accessed, then you could block access to the table and do a file copy of the table. Sorry that I could not be of more help on item 2. Doug www.parsonstechnical.com - Original Message - From: Frank Burns [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 9:04 AM Subject: Database backups initiated from Tomcat Hi, I have an urgent requirement where I have to initiate a database backup (of three mySQL tables) prior to performing an upload and update of the database. The preferred method of backing up is to use the mysqldump script. Can anyone: 1) tell me whether this is possible -- i.e., running the mysqldump script from a servlet 2) give me any clues/details on the best way to do this? Thanks, Frank. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
Thanks Tom, I'm using linux. So you think running Runtime.getRuntime().exec(String cmdline) from within a Servlet is viable? Can you think of any potential issues with using this solution? I'm just trying fathom, as quickly as possible, whether there are any show stoppers in taking this route. Frank. - Original Message - From: Tom K [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 2:45 PM Subject: RE: Database backups initiated from Tomcat What operating system are you using? It is possible to call System (and database) commands within java to execute the mysqldump script. For example for basically any operating system you can execute a Runtime.getRuntime().exec(String cmdline) Tom Kochanowicz -Original Message- From: Frank Burns [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 8:05 AM To: Tomcat Users List Subject: Database backups initiated from Tomcat Hi, I have an urgent requirement where I have to initiate a database backup (of three mySQL tables) prior to performing an upload and update of the database. The preferred method of backing up is to use the mysqldump script. Can anyone: 1) tell me whether this is possible -- i.e., running the mysqldump script from a servlet 2) give me any clues/details on the best way to do this? Thanks, Frank. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
I'm not sure if getRuntime().exec(String cmdline) is synchronous or not. Also I don't know if mySql makes any provisions for locking a table during a dump. Those are the questions I would want answered before going ahead. On Wednesday 19 May 2004 10:15 am, Frank Burns wrote: So you think running Runtime.getRuntime().exec(String cmdline) from within a Servlet is viable? Can you think of any potential issues with using this solution? I'm just trying fathom, as quickly as possible, whether there are any show stoppers in taking this route. -- Ben Souther - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database backups initiated from Tomcat
Hi, Oooh, it's been a while since someone raised an exec() solution on the ilst, so it's worth bringing up a few points ;) I'm not sure if getRuntime().exec(String cmdline) is synchronous or not. It's a non-blocking call. What you get back is a java.lang.Process object. You can read from this process (using the getInputStream method), write to it (getOutputStream), and check its status. It's common to use the waitFor method to wait until the process is done in order to achieve a close equivalent to a synchronous or blocking exec call. Of course, using waitFor to lock up your request processing thread is not that good an idea ;) But it's possible and doable. Security concerns abound. You want to make sure the command executed by exec is not related to the request parameters, or you will be an easy target for hackers (or unhappy coworkers in the case of an intranet). Consider: Runtime.getRuntime.exec(someScript -employeeId= + req.getParameter(employeeId)); What happens if someone calls your servlet with http://yourhost:yourport/yourwebapp/yourservlet?employeeId=1;rm%20* ? ;) The SecurityManager's checkExec method is invoked before execution, so it's a good idea to run with a SecurityManager and setup the exec permissions carefully. Yoav This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
mySQL has the locking table you need . It depends of the version of the server you are testing. LOCK TABLES yourtable lockmode; http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html - Original Message - From: Ben Souther [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 4:28 PM Subject: Re: Database backups initiated from Tomcat I'm not sure if getRuntime().exec(String cmdline) is synchronous or not. Also I don't know if mySql makes any provisions for locking a table during a dump. Those are the questions I would want answered before going ahead. On Wednesday 19 May 2004 10:15 am, Frank Burns wrote: So you think running Runtime.getRuntime().exec(String cmdline) from within a Servlet is viable? Can you think of any potential issues with using this solution? I'm just trying fathom, as quickly as possible, whether there are any show stoppers in taking this route. -- Ben Souther - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database backups initiated from Tomcat
I'm not sure either, but you could try it in a sync block and see if it works and let us know ;-) I use mySQL, and this is an issue I will tangle with too...so let the list know what works for you. You might also want to look at some scheduling software like quartz http://www.opensymphony.com/quartz/ you can set it up to schedule jobs at any time, recurring and likewise. Tom Kochanowicz -Original Message- From: Ben Souther [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 9:28 AM To: Tomcat Users List Subject: Re: Database backups initiated from Tomcat I'm not sure if getRuntime().exec(String cmdline) is synchronous or not. Also I don't know if mySql makes any provisions for locking a table during a dump. Those are the questions I would want answered before going ahead. On Wednesday 19 May 2004 10:15 am, Frank Burns wrote: So you think running Runtime.getRuntime().exec(String cmdline) from within a Servlet is viable? Can you think of any potential issues with using this solution? I'm just trying fathom, as quickly as possible, whether there are any show stoppers in taking this route. -- Ben Souther - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Database backups initiated from Tomcat
On Wednesday 19 May 2004 04:22 pm, Tom K wrote: I'm not sure either, but you could try it in a sync block and see if it works and let us know ;-) Yoav Shapira answered that. (getRuntime().exec is non-blocking) Read his reply for the details. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database backups initiated from Tomcat
But ?? can't you do something like this public static final void openFileAndExecuteAssociatedApplication(String fullPathAndFileName){ try { Process p = Runtime.getRuntime().exec(cmd /c start +fullPathAndFileName); p.waitFor(); } catch (Throwable ex) { ex.printStackTrace(); } } I do agree that some of this Runtime stuff is dangerous. I'm just trying to help, but I don't want to waste time, so this is my last post regarding this topic. If anyone has a proven solution please share and leave the corrections to God! Tom Kochanowicz -Original Message- From: Ben Souther [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 19, 2004 3:37 PM To: Tomcat Users List Subject: Re: Database backups initiated from Tomcat On Wednesday 19 May 2004 04:22 pm, Tom K wrote: I'm not sure either, but you could try it in a sync block and see if it works and let us know ;-) Yoav Shapira answered that. (getRuntime().exec is non-blocking) Read his reply for the details. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]