Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-2008, 02:06 AM
Partner (VAR/HSP)
 
Posts: 425
Default Backup delete script

Hello!
For performance reasons, I do not want to use rsync with the --delete option to sync the /opt/zimbra/backup directory with our backup server.

I am looking for a good, proven script that deletes all backups taht are, say, older than 21 days, and runs directly on the backup server.

Do you have any good ones?

Thanks

Chris
Reply With Quote
  #2 (permalink)  
Old 11-23-2008, 07:04 AM
Moderator
 
Posts: 1,554
Default

could you do it simply with a find command? like

Code:
find /opt/zimbra/backup/sessions -depth 1 -ctime +21 -exec rm -rf {} \;
this would basically find any directories in /opt/zimbra/backup/sessions that are over 21 days from creation and rm -rf them.

anyone see why this wouldn't work?
Reply With Quote
  #3 (permalink)  
Old 11-23-2008, 01:18 PM
Partner (VAR/HSP)
 
Posts: 425
Default

The thing is, I need it to be more clever than that, since this solution would delete, for example, the full backup of october 20th, and leave the incrementals of 21st, 22nd, etc. These are of no use without the underlying full backup, are they?

Thanks

Chris
Reply With Quote
  #4 (permalink)  
Old 11-24-2008, 05:12 AM
Moderator
 
Posts: 1,554
Default

yeah you're right the incrementals would be useless without the preceeding full.
Reply With Quote
  #5 (permalink)  
Old 11-24-2008, 10:44 AM
Moderator
 
Posts: 1,147
Default

What backup script are you using? Without knowing the structure of your backups this would be rather hard to answer...
Reply With Quote
  #6 (permalink)  
Old 11-24-2008, 12:58 PM
Partner (VAR/HSP)
 
Posts: 425
Default

Zimbra NE just uses the Network Edition Backup schedule, the backup directory is then rsynched to a remote server once a night.
Reply With Quote
  #7 (permalink)  
Old 11-24-2008, 09:34 PM
Junior Member
 
Posts: 8
Default

Here's a script I use for backing up stuff. Adjust the the number 21 to reflect however many files you'd like to keep. Of course, this is no good for incremental backups, only fulls.

Code:
#if the number of files in the backup folder is greater than or equal to 21
if [ $(ls %YOUR DESTINATION DIRECTORY% | wc -l) -ge 21 ]
then
        #navigate to backup directory
        cd %YOUR DESTINATION DIRECTORY%
        #remove the oldest file
        ls -1 -lt | awk ' /^-/ { print $9}' | tail -1 | xargs rm
        #create a new gzipped tar archive in the backup folder, using the current date in YYYY-MM-DD_24hr format as the filename.
        tar -czf %YOUR DESTINATION DIRECTORY%/$(date +%F)_$(date +%H%M).tar.gz %YOUR SOURCE DIRECTORY%
else
        #create a new gzipped tar archive in the backup folder, using the current date in YYYY-MM-DD_24hr format as the filename.
        tar -czf %YOUR DESTINATION DIRECTORY%/$(date +%F)_$(date +%H%M).tar.gz %YOUR SOURCE DIRECTORY%
fi
- Joe
Reply With Quote
  #8 (permalink)  
Old 08-06-2011, 08:23 AM
Starter Member
 
Posts: 1
Default

Quote:
Originally Posted by iway View Post
The thing is, I need it to be more clever than that, since this solution would delete, for example, the full backup of october 20th, and leave the incrementals of 21st, 22nd, etc. These are of no use without the underlying full backup, are they?

Thanks

Chris
This script deletes all backups (full and incremental) except the last full
and subsequent incrementals. It is not a perfect script (some incrementals
remains) but it's all you can do with just two commands.

#!/bin/sh
BCKDIR="/opt/zimbra/backup/sessions"
LIMIT=`ls -1drt $BCKDIR/full* | tail -2 | head -1`
find $BCKDIR -maxdepth 1 -type d -not -newer $LIMIT -delete


PS: i suggest you also to reprogram zimbra backup crontab
using zmschedulebackup
Reply With Quote
  #9 (permalink)  
Old 10-19-2011, 05:36 PM
Starter Member
 
Posts: 1
Default

Why not grab a copy of the script zimbra uses, modify and run it on the remote server. Just make sure the backups are completing.

/opt/zimbra/bin/zmbackup: perl script text executable

Edit: nevermind, I did not realize the perl script is just a wrapper.

Last edited by langseth; 10-20-2011 at 07:37 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.