CyberTek - the future at the present!
Google

Archive for the 'scripts' Category

Script to create mysql databases

Posted by: admin (Sep 21)

Today I am presenting a comfortable position to automate database saving nosri mysql database, in addition to the original script can be added at the end of the rescue and compression of individual databases in few lines the copy on a remote server and a message box in our report email.

#! / bin / bash
# Shell script to backup MySql database
# To backup databases Nysql files to / backup dir and later pick up by your
# Script. You can skip few databases from backup too.
# For more info please see (Installation info):
# Http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/01/mysql-backup-script.html
# Last updated: Aug - 2005
# -----------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2004, 2005 nixCraft project
# Feedback / comments / suggestions: http://cyberciti.biz/fb/
# -------------------------
# This script is part of nixCraft shell script collection (NSSC)
Visit # http://bash.cyberciti.biz/ for more information.
# Updated Sep - 2007 by CyberTek - http://www.cybertek.it
# -------------------------

Myuser = "SET-MYSQL-USER-NAME" # USERNAME
Mypass = "SET-PASSWORD" # PASSWORD
MyHOST = "localhost" # Hostname

# Linux bin paths, change this if it can not be autodetected via which command
MYSQL = "$ (which mysql)"
Mysqldump = "$ (which mysqldump)"
Chown = "$ (which chown)"
CHMOD = "$ (which chmod)"
GZIP = "$ (which gzip)"

# Backup Dest directory, change this if you have someother location
DEST = "/ backup"

# Main directory where backups will be stored
MBD = "$ DEST / mysql"

# Get hostname
HOST = "$ (hostname)"

# Get data in dd-mm-yyyy format
NOW = "$ (date +"% d -% m -% Y ")"

# File to store current backup file
FILE = ""
# Store list of databases
DBS = ""

# DO NOT BACKUP these databases
IGGY = "test"

[- D $ MBD] & & mkdir - p $ MBD | |:

# Only root can access it!
Chown $ 0.0 - R $ DEST
$ CHMOD 0600 $ DEST

# Get all database list first
DBS = "$ ($ MYSQL-u myuser-h $ $ $ MyHOST-p mypass-BSE 'show databases')"

for db in $ DBS
do
skipdb = - 1
if [ "$ IGGY"! = ""];
then
for i in $ IGGY
do
[ "$ Db" = = "$ i"] & & skipdb = 1 | |:
done
florence

if [ "$ skipdb" = = "-1"]; then
FILE = "$ MBD / $ db. $ HOST. NOW.gz $"
# Do all InOne job in pipe,
# Connect to mysql using mysqldump for select mysql database
# And pipe it out to gz file in backup dir:)
$ Mysqldump - u myuser $ - $ MyHOST h - p $ mypass $ db | $ GZIP - 9> $ FILE
florence

done

# Copy on remote server
echo'******************* Example_Backup *******************'> / root / mybackup.txt
echo \>> / root / mybackup.txt
date>> / root / mybackup.txt
echo \>> / root / mybackup.txt
'********************* Details *********************' echo>> / root / mybackup.txt
# remember that the scp command you can not specify the password if you have cleared a key on the target system
# otherwise you will have to do
scp / backup / mysql / * root@example.dom: / home / backup / example / mysql /
oh-ls / backup / mysql />> / root / mybackup.txt
echo'************************************************ * '>> / root / mybackup.txt
# send an email with the report of the work performed
mail-s "Example Backup" example@example.dom </ root / mybackup.txt

# remove after upload
rm-f / backup / mysql / *

Script to backup to dvd

Posted by: admin (Aug 29)

The following script is made a backup of some folders on dvd burn through, after a report is sent via email to the address. It is used M-mode (append) Asthe the-Z if started in a non-interactive does not work properly in the presence of data on the media, you can try using cmq growisofs-use-the-force-luke = tty-Z even in non-interactive mode while having the data already on the media.

Example:

Create a file and make it executable:

> Touch / bin / dvdbackup.sh

> Chmod 755 / bin / dvdbackup.sh

Add the following instructions:

#! / bin / bash
# Replace the hiring of the program with those of your operating system
Growisofs = / usr / bin / growisofs
ECHO = / bin / echo
GREP = / bin / grep
MAIL = / bin / mail
today = `/ bin / date +% A`
# Backup begins below
$ ECHO "Creating $ backup today">> / tmp / backupoutput.tmp
$ ECHO>> / tmp / backupoutput.tmp
$ Growisofs-use-the-force-luke = tty-dvd-compat-M / dev / dvd-D-J-R-T-l
-graft-points-joliet-long-hide-joliet-trans-tbl
-iso-level 4-speed = 1-overburn-V "$ today Backup"
etc / mail = / etc / mail
var / spool / mail = / var / spool / mail
home = / home
root = / root>> / tmp / backupoutput.tmp 2> & 1
# Change the paths to rescue over here as needed
mycode = $?
$ ECHO>> / tmp / backupoutput.tmp
$ ECHO "An error occurred, error code: $ mycode">> / tmp / backupoutput.tmp
$ ECHO>> / tmp / backupoutput.tmp
$ ECHO "End of today $ backup">> / tmp / backupoutput.tmp
$ GREP-i-v sleeping / tmp / backupoutput.tmp> / tmp/backupoutput.tmp2
$ GREP-i-v formatting / tmp/backupoutput.tmp2> / tmp / backupoutput.txt
$ MAIL-s-n "result of the backup to DVD" usermail @ domain </ tmp / backupoutput.txt

In crontab then simply add the schedule to start in invoking the backup:

> Crontab-e

Example line to be added:

0 20 * * * / bin / dvdbackup.sh

Published in: development, scripts, tips

Finding IP assets in a LAN

Posted by: admin (Jul 29)

Very simply to find the addresses under a LAN is simply use the command "nmap", of course from your preferred Linux Box.

Ex:

nmap-sP 192.168.1.0/24

Published in: linux, scripts, tips

Burn CD & DVD from Linux console

Posted by: admin (Jul 9)

In short commands to burn cd & dvd Linux console:

/ / delete / format a cd-rw device inserted in the "/ dev / hdd"

myhost: ~ # cdrecord-blank = fast-force dev = / dev / hdd

/ / write files in the path "/ backup" on device "/ dev / hdd"

myhost: ~ # mkisofs-v-R / backup | cdrecord-v fs = 4 speed = 40 dev = / dev / hdd --

/ / Write the files in the path "/ backup" on the dvd recorder device "/ dev / hdc"

myhost: ~ # growisofs-Z / dev / hdc-J-R / backup /

/ / To create an image to burn iso

# Mkisofs-r-o / tmp/var-www-disk1.iso / var / www

/ / Use growisofs to write the ISO image on the DVD

# Growisofs-Z / dev / dvd = / tmp/var-www-disk1.iso

/ / To add data to a dvd conente other data

# Growisofs-M / dev / dvd / tmp/file.1

/ / To format or erase a dvd

# Dvd + rw-format-force / dev / dvd

/ / Or

# Dvd + rw-format-force = full / dev / dvd

/ / To view info on the media

# Dvd + rw-MediaInfo / dev / dvd

After the pills as soon as we set out to read the following howto.

Published in: linux, scripts, shell, tips

Set a route to Linux

Posted by: admin (May 23)

Route is the Linux command that is used to manipulate the routing tables. Allows you to add and delete static route and default gateway, and simply display the routing table of a system. It is not common in other Unix.

route add [-net |-host] address [gateway gw] [netmask netmask] [mss mss] [metric metric] [dev device]
route of address


To add a static route for an entire network using the add option is devine and the network-manager. For example:
route add-net 192.168.0.0 netmask 255.255.255.0 gw 10.0.0.254
Adds a static route for network 192.168.0.0/24 using as a gateway 10.0.0.254.

To set the default gateway you can type something like:
route add-net 0.0.0.0 netmask 0.0.0.0 gw 10.0.0.1 or:
route add default gw 10.0.0.1

To delete an existing route can be done by stating the name of the network:
route del-net 192.168.0.0

To view the route table enough route, if you want to avoid the reverse lookup of the IP and speed up the write operation:

route-n

To view the cache of the system used on the route:

route-C

Published in: linux, scripts, shell, tips
Powered by CyberTek - Remote Assistance