rsync すごい(既存のoptionに便利なのがあった。賢い)
hard linkでバックアップを世代管理
test.sh
#!/bin/bash # delete oldest backup if [ -d test_bk10 ] ;then /bin/rm -rf test_bk10 fi # backup dir rename(lotate) for i in 9 8 7 6 5 4 3 2 1 0;do if [ -d test_bk"$i" ] ;then l=`expr $i + 1` mv test_bk$i test_bk$l; fi done # submit backup rsync -avzP --delete --link-dest=../test_bk1 test/ test_bk0
rsyncのoption説明
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) -v, --verbose increase verbosity -z, --compress compress file data during the transfer -P same as --partial --progress でかいサイズのファイルをrsyncで転送中に中断した場合、その後に再開すると中断後から行ってくれる! --link-dest=DIR This option behaves like --copy-dest, but unchanged files are hard linked from DIR to the destination directory. The files must be identical in all preserved attributes (e.g. permissions, possibly ownership) in order for the files to be linked together. An example: DIR は例の場合の「test_bk0」の相対パスを入力しないといけない。
- 考慮点・足りない点
- 世代管理は日付でやる予定
- renameももっとかっこよく出来る?
- rsyncのエラーハンドリングは必須