Solved

Linux Shell Script Challenge

Posted on 2007-03-28
2
355 Views
Last Modified: 2013-12-16
I am in a time crunch so am asking for as much guidance or samples as possible to accomplish the following in a shell script.

On an Ubuntu Edgy Eft server, do:

1. Stop Apache
2. Stop MySQL
3. tgz all files in webroot and date the archive (e.g. webrootbackup03282007.tgz)
4. tgz all MySQL databases and date the archive (e.g. mysqlbackup03282007.sql..tgz)
5. Start MySQL
6. Start Apache
7. Ship the archives to a Windows Server NTFS share
8. Delete the "local" copies of tgz's.
9. Email me a report

(I will then set cron to run the script as necessary...)
0
Comment
Question by:smetterd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 450 total points
ID: 18808813
Would be something like:
(
 /etc/init.d/apache stop;
 /etc/init.d/mysql stop;
 DATE=`date "+%Y%m%d"`
 tar -czf /tmp/webrootbackup${DATE}.tgz /your/webroot
 tar -czf /tmp/mysqlbackup${DATE}.tgz /var/lib/mysql
 /etc/init.d/mysql start;
 /etc/init.d/apache start;
 smbmount //windows/share /mnt
 mv /tmp/webrootbackup${DATE}.tgz /tmp/mysqlbackup${DATE}.tgz /mnt
 smbumount /mnt
) | mail -s "backup report" you@example.com

Can't tell you if the pathe to the start-scripts are correct that way, only have a SuSE-box
0
 
LVL 25

Assisted Solution

by:Cyclops3590
Cyclops3590 earned 50 total points
ID: 18809069
hrnst42 pretty much nailed it;  however personally whenever stopping and restarting critical services, I'd put in extra checks on those in case an error happens
example, (provided the apache stop exits with an error code if it fails; like it should)
 /etc/init.d/apache stop || mail -s "apache stop error" you@example.com && exit 1

then you know where the script received an error and exits the script so not to potentially cause any problems with future commands.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question