Sambaでディレクトリツリーを保持したごみ箱(もどき)を使う

ネタ元:[samba-jp:16828] Re: ゴミ箱にアクセスできない
smb.confで

  vfs objects = recycle
  recycle:repository = .recycle/%u
  recycle:keeptree = yes

とすると、ディレクトリツリーを保ったままごみ箱(もどき)にファイルが待避される。
例えば、ユーザーhirose31がfoo/bar/baz.txtbaz.txtを削除すると、.recycle/hirose31/foo/bar/baz.txtにファイルが移動する。
あとは定期的にお掃除するスクリプトをしこんでおけばよいかと。7日以上古いのを削除するのはこんな感じすかね。

#! /bin/sh

recycle='
/path/to/shared/volume1/.recycle
/path/to/shared/volume2/.recycle
'
logfile=/var/tmp/cleanup-recycle.log

for d in ${recycle}; do
    chown root:users $d
    chmod 775 $d
done

find ${recycle} -not -mtime -7 -type f  >${logfile}
find ${recycle} -not -mtime -7 -type d >>${logfile}
find ${recycle} -not -mtime -7 -type f -print0 | xargs -0 rm -f 2>/dev/null
find ${recycle} -not -mtime -7 -type d -print0 | xargs -0 rmdir 2>/dev/null