LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-24-2005, 10:03 AM   #46
jonhewer
Member
 
Registered: Apr 2005
Location: London, UK
Distribution: Debian Lenny, Debian Etch, Ubuntu Hardy
Posts: 71

Original Poster
Rep: Reputation: 15

yeh when i was in 6th form i had to use visual basic....it sucks, and it has put behind now at uni cos most of the other people on my course (computer science) have experience with c and c++

Last edited by jonhewer; 08-24-2005 at 10:16 AM.
 
Old 08-24-2005, 05:31 PM   #47
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Quote:
Originally posted by jonhewer
Code:
find /var/backup -name "backup-*" -mtime +7 -exec rm -v '{}' \;
find is a tool used to search for files - i will explain what the above command does:

/var/backup is the base directory to search in

-name "backup-*" means i want all files beginning with backup-

-mtime +7 matches files last modified more than 7 days ago

-exec rm-v '{}' \; deletes the files, -v for verbose

this is all explained in the manual

HTH
Thanks jonhewer

I'll have a mess around with the code to get it to work
 
Old 08-25-2005, 02:41 AM   #48
jonhewer
Member
 
Registered: Apr 2005
Location: London, UK
Distribution: Debian Lenny, Debian Etch, Ubuntu Hardy
Posts: 71

Original Poster
Rep: Reputation: 15
no problem

would you mind posting ur entire script once complete, it looks handy
 
Old 08-25-2005, 04:50 AM   #49
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Be happy to post it, hopefully have it finished by the weekend, just will depend on study and work this weekend.

Last edited by fotoguy; 08-25-2005 at 04:54 AM.
 
Old 08-25-2005, 09:09 AM   #50
jonhewer
Member
 
Registered: Apr 2005
Location: London, UK
Distribution: Debian Lenny, Debian Etch, Ubuntu Hardy
Posts: 71

Original Poster
Rep: Reputation: 15
Hi

This message is mostly intended for tomj88 or anyone who has grabbed my whole script.....i have come across a small problem with the mysqldump command:

Code:
mysqldump -u $mysqluname -p $mysqlpass $mysqldb > backup-$date.sql 2>>backuplog
I took this code directly from a guide to backing up a mysql db, and even tho I was specifying the password in the command, I was still being prompted for it. I figured this was because I had been using the 'root' mysql user, but infact this is not the case. I have changed the syntax of this command to:

Code:
mysqldump -u $mysqluname --password=$mysqlpass $mysqldb > backup-$date.sql 2>>backuplog
And it now works without prompting for the password.

Cheers
Jon
 
Old 08-25-2005, 10:49 AM   #51
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
Thanks for that... another solution is to set up a user with very basic privileges. For exam, you database is called site, then you have a user called site that only has select privileges on that table. You can do this by opening up mysql at the command line and typing:
GRANT select ON site.* TO 'site'@'localhost';
You could make it so this user can do anything he/she likes on that database (such as select, insert, drop) by going:
GRANT ALL PRIVILEGES ON site.* TO 'site'@'localhost';
If you restrict the users as much as possible, atleast you won't accidently delete your database when running a php script, or be as vunerable to mysql injection attacks for example.
 
Old 08-25-2005, 11:45 AM   #52
jonhewer
Member
 
Registered: Apr 2005
Location: London, UK
Distribution: Debian Lenny, Debian Etch, Ubuntu Hardy
Posts: 71

Original Poster
Rep: Reputation: 15
i have done this in fact

i was just using root during development just because it was easier, but now that i have implemented my php & mysql application, i have set up a special mysql account for this
 
Old 09-07-2005, 07:12 AM   #53
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Quote:
Originally posted by jonhewer
no problem

would you mind posting ur entire script once complete, it looks handy
Heres the script, not too sure if the deleting old files works. To get the right 'cdrecord dev=ATAPI:0,0,0 just run at the command line:

cdrecord dev=ATAPI -scanbus

You should get something similar to this:

scsibus0:
0,0,0 0) 'Slimtype' 'COMBO SOSC-2483K' 'KCK2' Removable CD-ROM
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *


#!/bin/sh

Backup_Dirs="/home/bill/mail" # eg. /etc /usr/local /opt /var /root /boot note: you can have multiple directories seperate by a space
Backup_Dest_Dir=/tmp/backup
Backup_Date=`date +%b%d%Y`
Speed=8 # Use best speed for CD-R/RW disks on YOUR system

echo "StartingBackup"

# Check to see of backup directory exists, if not then create it

if [ ! -d $Backup_Dest_Dir ]; then
mkdir $Backup_Dest_Dir
else
echo "Backup Directory already exists"
fi

echo "Backup Date: $Backup_Date" > $Backup_Dest_Dir/backup-$Backup_Date.log
echo "Backup Directories: $Backup_Dirs" >> $Backup_Dest_Dir/backup-$Backup_Date.log
echo "" >> $Backup_Dest_Dir/backup-$Backup_Date.log
echo "Files backed-up:" >> $Backup_Dest_Dir/backup-$Backup_Date.log

# Create tar file with todays Month Day Year prepended for easy identification

tar -cvzf $Backup_Dest_Dir/backup-$Backup_Date.tar.gz $Backup_Dirs >> $Backup_Dest_Dir/backup-$Backup_Date.log

echo "Created backup-$Backup_Date.img including log file"

# Create a image that can be written to writeable media

mkisofs -r -o $Backup_Dest_Dir/backup-$Backup_Date.img $Backup_Dest_Dir/backup-$Backup_Date.tar.gz $Backup_Dest_Dir/backup-$Backup_Date.log

# Check size of directory to burn in MB

Size=`du -m $Backup_Dest_Dir/backup-$Backup_Date.img | cut -c 1-3`

if [ $Size -lt 680 ];then
echo "Size of backup-$Backup_Date.img is $Size MB, OK to Burn"
else
echo "Size of backup-$Backup_Date.img too Large to burn too CD-R....Maybe time for DvD Burner"
exit 1
fi

# Burn the CD-RW

echo "Burning back-up to disc."

cdrecord dev=ATAPI:0,0,0 -v -eject fs=64M driveropts=burnproof speed=$Speed -tao $Backup_Dest_Dir/backup-$Backup_Date.img

echo "Successfully backed-up backup-$Backup_Date.img to cd-r/rw"

# Lets check for backups and log files older than 7 days and delete them

find /tmp/backup -name "backup-*" -mtime +7 -exec rm -v '{}' \;

exit 0
 
Old 09-07-2005, 09:11 AM   #54
tomj88
Member
 
Registered: Apr 2005
Location: Wolverhampton, England
Distribution: Ubuntu
Posts: 334

Rep: Reputation: 30
Thanks for that, might start using it myself... I need to start backing up more regularly...
 
Old 09-09-2005, 02:58 PM   #55
jonhewer
Member
 
Registered: Apr 2005
Location: London, UK
Distribution: Debian Lenny, Debian Etch, Ubuntu Hardy
Posts: 71

Original Poster
Rep: Reputation: 15
cheers fotoguy!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
bash scripting --- some help needed rajsharma Linux - Software 1 09-09-2005 02:49 AM
Scripting help needed. stonelee Linux - Software 2 09-29-2003 09:47 AM
Shell scripting and background processes - help needed. trafalgar Programming 3 06-08-2003 09:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration