Archive and Restore


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Archive and Restore
# 1  
Old 12-02-2009
Archive and Restore

Can someone please let me have a nice shell script to:

1) Identify all folders/sub-folders/files older than 365 days with the exception of one or two folders e.g. named - "common" or "test"
2) Archive (1) above for example in a TAR file
3) Delete all in (1) above
and that's it...
4) In case of some failure, restore (1) above to its original state.

Please note, I tried various Unix commands e.g. find . -mtime +365 -type d ! -name common -exec rm -r {} \;

Please note the using TAR -xvf i.e. to restore the files changes the timestamp of the folders to current timestamp, I want these to be restored back to the original timestamp.

Regards.
# 2  
Old 12-03-2009
Quote:
Please note the using TAR -xvf i.e. to restore the files changes the timestamp of the folders to current timestamp, I want these to be restored back to the original timestamp.
cpio will restore the original timestamp:
Code:
ant:/home/vbe $ ll zi*

ziza:
total 0
drwxrwxr-x   3 vbe        bin             96 Dec  3 17:27 001

zizi:
total 0
ant:/home/vbe $ ll -ld zi*
drwxrwxr-x   3 vbe        bin             96 Dec  3 17:27 ziza
drwxrwxr-x   2 vbe        bin             96 Dec  3 19:23 zizi
ant:/home/vbe $ find  ziza -depth|cpio -pduml zizi
0 blocks
ant:/home/vbe $ cd zizi;ll
total 0
drwxrwxr-x   3 vbe        bin             96 Dec  3 17:27 ziza
ant:/home/vbe/zizi $ ll ziza/*
total 0
drwxrwxr-x   3 vbe        bin             96 Dec  3 17:27 002
ant:/home/vbe/zizi $ ll ziza
total 0
drwxrwxr-x   3 vbe        bin             96 Dec  3 17:27 001
ant:/home/vbe/zizi $

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. AIX

How to restore rootvg archive after AIX 6.1 crash

Hello, Few days ago I created both mksysb and savevg archives of rootvg. How can I restore this rootvg now because the AIX crashed during some software tests. There is no way to start from hdisk0 because most of the system files are deleted (this includes libc.a). I tough it will be trivial... (6 Replies)
Discussion started by: +Yan
6 Replies

3. Solaris

Restore from Flash Archive on local filesystem

I am doing a practice restore using a test UNIX(Solaris) system, and a SCSI Hard Drive whose slice 5 contains the Flash Archive file that I need to restore from. The test system is offline( no network ) and does not have external devices, such as tape drive. My goal is to somehow restore the... (9 Replies)
Discussion started by: the.gooch
9 Replies

4. UNIX for Dummies Questions & Answers

Unable to restore cpio archive to a directory

Hello Every one, I want to back up all passwd files to /xyz/passfiles.cpio and Then restore them to /abc directory. Here is what I wrote: find / -name passwd | cpio -oc > /tmp/passwd.cpio and to restore cd abc cpio -ium < /tmp/passwd.cpio I can not find the files restored to /abc... (2 Replies)
Discussion started by: drdigital_m
2 Replies

5. Shell Programming and Scripting

Extracting from archive | compressing to new archive

Hi there, I have one huge archive (it's a system image). I need sometime to create smaller archives with only one or two file from my big archive. So I'm looking for a command that extracts files from an archive and pipe them to another one. I tried the following : tar -xzOf oldarchive.tgz... (5 Replies)
Discussion started by: chebarbudo
5 Replies

6. Solaris

Can I restore from a flash archive without re-entering the basic sys info?

Hi I would like to be able to take adhoc backups of my systems using flash archive - flarcreate - and then restore from them to the same system without having to enter the basic configuration again when I boot from the Solaris CD. So, I'd like to be able to create a flar archive ... (1 Reply)
Discussion started by: emjs
1 Replies

7. AIX

mksysb restore - Wrong OS level for restore

Hi all, I am still working on my mksysb restore. My latest issue is during an alt_disk_install from tape I got the following error after all the data had been restored. 0505-143 alt_disk_install: Unable to match mksysb level 5.2.0 with any available boot images. Please correct this... (0 Replies)
Discussion started by: pobman
0 Replies

8. UNIX for Dummies Questions & Answers

Selective restore from a cpio tape archive

Hi, I use following command to restore data from my cpio tape archive: $cpio -icvd < /dev/rct0 But this'll restore all tape contents to the current path, what if I want only selected files from the tape, suppose I want /home/compdir/home2/Rev83/data/PL/01/*.* files to be restored... (8 Replies)
Discussion started by: tayyabq8
8 Replies
Login or Register to Ask a Question