?
Solved

qmail backup zip method

Posted on 2007-10-04
13
Medium Priority
?
363 Views
Last Modified: 2013-12-02
I'm using qmail.
I forward all emails from email@xxx.com to email2@xxx.com to make email2@xxx.com my backup accounts.

I have the below commands to Zip up all qmail backup files.

cd
cd /xvmailhome/domains/MyDomain.com
tar cvf /backup/MyDomain.gz *2                'This command tars only those accounts ending with 2
rm -rf ./*2

I realised this sometimes creates very huge files which are difficult to unzip.
How can I modify it so it goes into every single email account ending with 2 and creates a single .gz file for Each Email Account ending with 2.

tar cvf /backup/MyDomain/EmailAccount2.gz *2    

Take note I might repeat the process for different domains.
0
Comment
Question by:dennisdominic
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20012865
Hi,

Since you are not going to tar then zip the files, then you can copy each file into a dir, zip and zip the copy:

mkdir /mydir (make sure that  you have enough space)
cd /xvmailhome/domains/MyDomain.com
for file in *2
do
    cp $file /mydir/$file
    gzip /mydir/$file
done

You may then do whatever you want with the zipped files (like backup on tape, etc.).

If you intend to keep the zipped files on-line then you may create a separate dir for each domain and repeat the above by replacing /mydir with each domain dir.

0
 
LVL 19

Expert Comment

by:http:// thevpn.guru
ID: 20012866
cd
cd /xvmailhome/domains/MyDomain.com
ls *.2 | tar cvf
rm -rf ./*2

try this
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20015404
First will not work for folders with whitespaces (common problem)
The second will not work at all (or I don't know how to use tar).

ls -1 *2 | while read f; do
 tar czf "/backup/MyDomain_$f.tar.gz" "$f"
done
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 1

Author Comment

by:dennisdominic
ID: 20019013
omarfarid's method gave me this...

cp: omitting directory `a2'
gzip: /backup/a2: No such file or directory
cp: omitting directory `b2'
gzip: /backup/b2: No such file or directory
cp: omitting directory `c2'
gzip: /backup/c2: No such file or directory
cp: omitting directory `c2'
0
 
LVL 1

Author Comment

by:dennisdominic
ID: 20019039
ravenpl's method..  I think it's almost there..


/backup/dlim/MyDomain_achong2: Unknown host
tar: /backup/dlim/MyDomain_a2\:.tar.gz: Cannot open: Input/output error
tar: Error is not recoverable: exiting now
tar: Maildir: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
tar: : Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
/backup/dlim/MyDomain_b2: Unknown host
tar: /backup/dlim/MyDomain_b2\:.tar.gz: Cannot open: Input/output error
tar: Error is not recoverable: exiting now
tar: Maildir: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20019878
Can You give here whole script? And "ls -1 2*" output?
> /backup/dlim/MyDomain_achong2: Unknown host
That's really strange - unknown host...
> /backup/dlim/MyDomain_a2\:.tar.gz
even stranger, where from that "\:" came from?
> Cannot open: Input/output error
You sure it's accessible?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20020094
Hi,

The error is because it is a directory. Here a modified one:

mkdir /mydir (make sure that  you have enough space)
cd /xvmailhome/domains/MyDomain.com

for dir  in *2
do
    tar czf /mydir/$dir.tar.gz  $dir
done
0
 
LVL 1

Author Comment

by:dennisdominic
ID: 20020325
omoarfarid method


tar (child): /backup/mydir/a2.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
Broken pipe
tar (child): /backup/mydir/b2.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
Broken pipe
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20021012
Hi,

What is the perms on the /backup and /backup/mydir ?

Can you run the following on your  system and let us see what you will get:

tar czf /backup/mydir/etc.tar /etc

The above command will create a compressed tar file (etc.tar) in /backup/mydir for /etc dir.

0
 
LVL 1

Author Comment

by:dennisdominic
ID: 20032235
[root@ns /]# tar czf /backup/dlim/etc.tar /etc
tar: Removing leading `/' from member names

Maybe I should rephrase my question again.
I'm running qmail, and all the email accounts are forwarded to *2 as backup.. so emailA will have a copy on emailA2, emailB will have a copy on emailB2... so I just zip up all the *2 accounts to backup.

the emails are in xvmailhome/domains/myDomain/emailA emailB and so on...
my old command below will create with a super huge Zip of all the user accounts ending with *2,

cd /xvmailhome/domains/MyDomain.com
tar cvf /backup/MyDomain.gz *2                'This command tars only those accounts ending with *2
rm -rf ./*2        'deletes all the emails inside the accounts ending with *2

but instead of that, I want a Zip file for each email account... so instead of MyDomain.gz
I will end up with   /MyDomain/emailA2.gz ,   /MyDomain/emailB2.gz ,   /MyDomain/emailC2.gz

one zip per email account...
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 750 total points
ID: 20032890
Hi,

Ok, that is what the script should do, but for some reason you are getting error message.

The next step is to

cd /xvmailhome/domains/MyDomain.com # where the directories are

we want to test backing up of of those directories manually

e.g. run

tar czf /backup/mydir/emailA2.tar.gz  emailA2 # this should create a zipped tar file for emailA2 in /backup/mydir
0
 
LVL 1

Author Comment

by:dennisdominic
ID: 20033038
strange.. but it works now.
btw, what's the difference between .tar.gz and just .gz?


for dir in *2
do
    tar czf /backup/myDir/$dir.tar.gz  $dir
done
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20033049
Hi,

I have no idea.

So, the subdirs can be backed up now.

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

579 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