Are you wanting someone to write the whole script for you, or are you just
wanting help getting started? Personally I would suggest writing it yourself
so you get experience with shell scripts. They are a powerful tool for any
administrator.
Your script fails to delete the files after it backs them up.
So let's break down your requirements. These are the subsections of the
script to work on:
1. Script runs for all users.
2. Backup files >30 days old in ~/Maildir/backup for each user.
3. Delete files >30 days after backed up.
For 1, best option is to run this script as a cron job when there is little
load on the server (midnight for example).
For 2, a simple for loop will run the backup commands for each user in
"/home". Example: "for user in /home/*; do {backup and delete commands};
done". You would use $user/Maildir/backup as the variable in the commands.
For 3, I use the command "find $BACKUPDIR -mtime +68 -delete" to keep just
over 2 months of backups, and then delete them. I use +68 so it keeps a full
week plus one day accounting for 31 days in a single month. You can modify
this and add to the for loop.
That should give you enough to get started. There are many resources on the
web for shell script help. If you get stuck, post what you have for your
script and point out where you are having problems.
Jeremiah E. Bess
Network Ninja, Penguin Geek, Father of four
On Wed, Nov 18, 2009 at 23:50, Nelson Serafica <[email protected]> wrote:
> All my user has a directory called backup on each of their home
> directory. All files was a text file. I want to backup those file after
> a month had past using tar and delete the text files after I tar it.
>
> Here is my some of the command I'm thinking of
>
> Quote:
> #!/bin/bash
>
>
> DATE=`date --date="1 month ago" | awk '{print $2}'`
>
> ls -l /home/user/Maildir/backup/ | grep $DATE | awk '{print $9}' | xargs
> tar crvf user-200910.tar.gz
>
> I want to apply this command to all my users in the server. I just want
> to ask some guru in scripting.
>
> Is my script suitable to what I need? Is there any possibility of
> bottleneck that might cause slow on the server? How can I apply this
> script to all user's backup dir and each has their own filename?
>
> --
> You received this message because you are subscribed to the Linux Users
> Group.
> To post a message, send email to [email protected]
> To unsubscribe, send email to [email protected]
> For more options, visit our group at
> http://groups.google.com/group/linuxusersgroup
--
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at
http://groups.google.com/group/linuxusersgroup