LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 09-14-2007, 08:25 AM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Script To Backup Email


I was looking at a script I inherited from the previous admin that works quite nice. It is a basic bash script that that deletes the user from mail groups (mailman) and also backs up their current email into a nice tarball and then removes their mail / shell account from the email server.

Now the script moves the backup tarball to a directory called /var/backup and I will show what I see...

Code:
[root@mail /]# cd /var/backup/
[root@mail backup]# ls -l
total 1120020
-rw-r--r--  1 root root   6537216 Jan 25  2007 -01-25-2007_10-44.tar.gz
-rw-r--r--  1 root root  10673918 Jul  9 10:16 abashir-07-09-2007_10-16.tar.bz2
-rw-r--r--  1 root root      1292 Jul 10 08:18 amaldonado-07-10-2007_08-18.tar.bz2
-rw-r--r--  1 root root   3205294 Feb  5  2007 cnguyen-02-05-2007_11-09.tar.gz
-rw-r--r--  1 root root   2740685 Mar  9  2007 cweiler-03-09-2007_13-07.tar.gz
-rw-r--r--  1 root root     10818 Apr 16 14:36 dbennett-04-16-2007_14-36.tar.gz
-rw-r--r--  1 root root   3064447 Feb 16  2007 dcasey-02-16-2007_09-30.tar.gz
-rw-r--r--  1 root root      9053 Apr  2 15:33 dcocchi-04-02-2007_15-33.tar.gz
-rw-r--r--  1 root root     44856 Mar 31 08:03 decheverria-03-31-2007_08-03.tar.gz
-rw-r--r--  1 root root     32379 Apr  4 08:28 dfranck-04-04-2007_08-28.tar.gz
Yeah so I wanted to clean this up manually and the first one for some reason can't be deleted. I don't know why.

Code:
[root@mail backup]# rm -01-25-2007_10-44.tar.gz 
rm: invalid option -- 0
Try `rm --help' for more information.
[root@mail backup]# rm -rf -01-25-2007_10-44.tar.gz 
rm: invalid option -- 0
Try `rm --help' for more information.
Any thoughts?
 
Old 09-14-2007, 08:37 AM   #2
Brydon
Member
 
Registered: Dec 2006
Location: Lancaster, Ontario
Distribution: Fedora 6-7, CentOS 5, Red Hat 9, Ubuntu
Posts: 36

Rep: Reputation: 15
From what i see in your command, you are trying to pass the parameter "-01-25-2007_10-44.tar.gz" to rm which of course does not exist.

Try:

[root@mail backup]# rm -i *-01-25-2007_10-44.tar.gz

The -i makes the command interactive, always good while you are root and the * makes the wildcard select everything before the -01-25-2007_10-44.tar.gz

You can also try either quotes "" or the back ticks ` to isolate the file name.

Good luck!

Last edited by Brydon; 09-14-2007 at 08:41 AM.
 
Old 09-14-2007, 08:40 AM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
I have no idea why I can't remove this file...

Code:
[root@mail backup]# rm -i *-01-25-2007_10-44.tar.gz
rm: invalid option -- 0
Try `rm --help' for more information.
Code:
[root@mail backup]# file -01-25-2007_10-44.tar.gz 
file: invalid option -- 0
file: invalid option -- 1
file: invalid option -- -
file: invalid option -- 2
file: invalid option -- 5
file: invalid option -- -
file: invalid option -- 2
file: invalid option -- 0
file: invalid option -- 0
file: invalid option -- 7
file: invalid option -- _
file: invalid option -- 1
file: invalid option -- 0
file: invalid option -- -
file: invalid option -- 4
file: invalid option -- 4
file: invalid option -- .
file: invalid option -- t
file: invalid option -- a
file: invalid option -- .
file: invalid option -- g
Usage: file [-bcikLnNsvz] [-f namefile] [-F separator] [-m magicfiles] file...
       file -C -m magicfiles
Try `file --help' for more information.
 
Old 09-14-2007, 09:03 AM   #4
Brydon
Member
 
Registered: Dec 2006
Location: Lancaster, Ontario
Distribution: Fedora 6-7, CentOS 5, Red Hat 9, Ubuntu
Posts: 36

Rep: Reputation: 15
Ok first of all, never answer questions before the first cup of coffee. My first answer will not work.

Lets find the inode number of the file.

[root@mail backup]# ls -li

655428 -rw-r--r-- 1 root root 6537216 Jan 25 2007 -01-25-2007_10-44.tar.gz

now let remove the inode

[root@mail backup]# find . -inum 655428 -exec rm -i {} \;

Where the inode number is the first number reported from ls.

Thanks for the morning challenge.
 
Old 09-14-2007, 09:49 AM   #5
Brydon
Member
 
Registered: Dec 2006
Location: Lancaster, Ontario
Distribution: Fedora 6-7, CentOS 5, Red Hat 9, Ubuntu
Posts: 36

Rep: Reputation: 15
Now that the coffee is kicking in...

After you have cleaned up the file, you should modify your backup script and replace the dash "-" with an underscore "_" between your user's name and the date. This will help prevent similar problems in the future.

Back to work now!
 
Old 09-14-2007, 10:17 AM   #6
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Thanks !!!

That worked!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Email backup wilku Linux - Server 2 03-28-2007 04:15 AM
Automatic backup to email critical Linux - Software 1 10-04-2006 05:47 AM
backup email users to new server wauchula Linux - Newbie 2 10-11-2005 03:33 PM
Backup of email LinuxLover Linux - Networking 3 09-24-2005 04:40 AM
How do I backup Mozilla email? barrythai Mandriva 4 01-23-2005 08:44 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 05:48 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