backup of files for a specific date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting backup of files for a specific date
# 1  
Old 07-30-2008
backup of files for a specific date

I want to write script for backing up archive logs files for specific date.
please give me idea for that.
# 2  
Old 07-30-2008
Quote:
Originally Posted by akm9999
I want to write script for backing up archive logs files for specific date.
please give me idea for that.
Okay, given the amount of information you gave here, the following are all valid (in increasing order of absurdity):

Since you specified neither flexibility nor name format:
Code:
mv /var/log/*20070821* /mnt/archive
gzip -9 /mnt/archive/*



Since you didn't say where you wanted them to go, nor what you wanted to do with them afterwords
:
Code:
mkdir "/dev/my backup directory"
mv /var/log/*2007* "/dev/my backup directory/"
sed -i '/:[0-9][0-5]:/ {d}' "/dev/my backup directory/*"

Finally, my pièce de résistance:
Code:
#!/bin/bash

if [ x$1 == x ]; then
    echo "Syntax: $0 <date>"
    exit 1
fi

cat $(grep -l $1 /var/log/*) | tar -cz | gzip -9 - > /dev/shm/archive-$1.tgz
rm -f $(grep -l $1 /var/log/*)

# 3  
Old 07-30-2008
backup of files for a specific date

I mean that I want to write script for backing up any useful files of specific date like 24/07/2008 to newly created folder.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files for a specific date

Hi, I am looking to find files of a specific date. I am on Sun Solaris so newermt doesnot work.. I thought of using mtime but not getting how to use it. Please help me with this.. Regards Abhinav (3 Replies)
Discussion started by: abhi1988sri
3 Replies

2. Shell Programming and Scripting

Find files with specific date

Dear all, kindly i have some files with different dates i need to grep word from these files but i need to search in files with date 2012-12-02 not all files in this directory do u have any command (4 Replies)
Discussion started by: maxim42
4 Replies

3. UNIX Desktop Questions & Answers

How to delete files from a specific date?

Guys, I am wondering how to remove files for a specific date in a directory? for instance when I do ls -l , i see many files. And i want to delete files for date May 15: 58252015 May 10 03:45 my_05102012.log 58252015 May 15 06:45 my_05152012.log Thanks (8 Replies)
Discussion started by: DallasT
8 Replies

4. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

5. Shell Programming and Scripting

getting files between specific date ranges in solaris

hi ! how can i get files in a directory between certain date ranges ? say all files created/modified between Jan24 - Jan31 thanks (10 Replies)
Discussion started by: aliyesami
10 Replies

6. Shell Programming and Scripting

How to backup latest date files?

Hi, I have below two situations to handle, 1. I have list of files with file names having date&time. I have to backup to old date files. say I have below files in a directory, 1. XX123_20101004010101.dat 2. XX124_20101004010201.dat 3. XX121_20101003010101.dat 4.... (6 Replies)
Discussion started by: smr_rashmy
6 Replies

7. Filesystems, Disks and Memory

backup of files for a specific date

In Linux Advance server I want to write one script for backing up files for a specific date like 24/07/2008. (3 Replies)
Discussion started by: akm9999
3 Replies

8. Shell Programming and Scripting

Backup files per Date String

Guys, I've got a quick logic question. I'm pretty savvy when it comes to shell scripting, however, I'm at a loss when it comes to writing a simple shell script to backup only certain files out of the month. I have a directory, for example, /data/backups/websites/domain. In each "domain"... (5 Replies)
Discussion started by: drewrockshard
5 Replies

9. Solaris

List files with a specific date...

Hi all, thanks in advance for reading and anyposts... I was wondering if its possible to find all files in a directory with a specific date. I know I can do: but that will only give a list of files greater than todays date... Any ideas? Thanks, Marky Mark... (4 Replies)
Discussion started by: B14speedfreak
4 Replies

10. Shell Programming and Scripting

backup files for a specific month

i am having a problem with writing a shell script to back up files for a specific month. the month and year are specified as paramters. so a backup of all the files modified during the specified month have to be made. for example if specify 200406 as my parameter, it should back up files that have... (3 Replies)
Discussion started by: problems
3 Replies
Login or Register to Ask a Question