find と cpio

find と cpio で、あるディレクトリ下の .asx ファイルのみをダンプ。
(asx をバッチで書き換えるため前準備としてバックアップ)

1. cpio によるバックアップ。

$ cat backup-asx
#!/bin/sh

## development
BASEDIR=/home/foo/wmv

TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S`
BACKUPFILE="$HOME/rewrite-asx/asx-backup-$TIMESTAMP.cpio.bz2"

find $BASEDIR -name \*.asx | cpio -o --format=newc | bzip2 > $BACKUPFILE

$

cpio で --format を省略すると、デフォルトの bin フォーマット (obsolete) になり、
"truncating inode number" などといわれる。

2. 内容を確認

$ bzcat asx-backup-2005-02-24-16\:42\:29.cpio.bz2 | cpio -it
/somewhere/243.asx
/somewhere/273.asx
/somewhere/274.asx
...
...
...
24 blocks
$

3. cpio の復元

i: input モード
d: 必要に応じてディレクトリの作成
m: modified time をアーカイブから復元

$ bzcat asx-backup2005-02-24-11\:55\:36.cpio.bz2 | cpio -idm
19 blocks
$ 

About this Entry

This page contains a single entry by dxy published on 2005年2月24日 16:25.

暗証番号について was the previous entry in this blog.

find と sed is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 5.01