LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Script To Backup Email (https://www.linuxquestions.org/questions/linux-enterprise-47/script-to-backup-email-584638/)

carlosinfl 09-14-2007 08:25 AM

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?

Brydon 09-14-2007 08:37 AM

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!

carlosinfl 09-14-2007 08:40 AM

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.


Brydon 09-14-2007 09:03 AM

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.

Brydon 09-14-2007 09:49 AM

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!

carlosinfl 09-14-2007 10:17 AM

Thanks !!!

That worked!


All times are GMT -5. The time now is 01:55 AM.