Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux Shell Script Challenge

Posted on 2007-03-28
2
Medium Priority
?
364 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 1800 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 200 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

604 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