Results 1 to 3 of 3
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 ...
- 11-19-2009 #1Linux Newbie
- Join Date
- Mar 2006
- Posts
- 101
cript to tar all files last month and place to another partition
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 file after I tar it.
Here is my some of the command I'm thinking of
I want to apply this command to all my users in the server. I just want to ask some guru in scripting.#!/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
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?
- 11-19-2009 #2Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
If you take this approach you will soon realize that you will end up dealing with files created in the same month (yes, same month only, years are not considered), this might not be a problem since you delete files backed up but still it's not an elegant way. Another problem it might cause is that if you file contains the name of the month, for example, Nov123.txt, it might be included in the list by mistake, if the creation time for the file is not in November.
The way I've been doing with this kind of task is to use command find (hint: option -newer, you'll need to touch two timestamp files to set the time range of the files that you will include in the backup list).
- 11-19-2009 #3Linux Newbie
- Join Date
- Mar 2006
- Posts
- 101
I don't think this would happen because of the files are all mail file (Maildir format). All emails are being duplicated in the backup folder.Another problem it might cause is that if you file contains the name of the month, for example, Nov123.txt


Reply With Quote