Created
January 19, 2012 12:52
-
-
Save brokendish/1639935 to your computer and use it in GitHub Desktop.
バックアップシェル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#--------------------------------------------------------- | |
# バックアップシェル | |
# | |
# perm1:格納先ディレクトリ | |
# ex) | |
# 第1周目なら /home/bkup/week-1 | |
# 第2周目なら /home/bkup/week-2 | |
# 第3周目なら /home/bkup/week-3 | |
# 第4周目なら /home/bkup/week-4 | |
# | |
#--------------------------------------------------------- | |
# | |
#入力パラメータチェック1 | |
if [ -z "$1" ] | |
then | |
echo "格納先ディレクトリを指定して!" | |
echo "ex) " | |
echo "第1周目なら /home/bkup/week-1" | |
echo "第2周目なら /home/bkup/week-2" | |
echo "第3周目なら /home/bkup/week-3" | |
echo "第4周目なら /home/bkup/week-4" | |
echo "" | |
echo "ディレクトリが存在しない場合は自動的に作成しちゃうよ!" | |
exit | |
fi | |
#------------------------------- | |
# ディレクトリ作成 | |
#------------------------------- | |
mkdir -p $1 | |
#------------------------------- | |
# homeディレクトリバックアップ | |
# ※「/home/bkup」は対象外とする | |
#------------------------------- | |
tar czf $1/home.tar.gz /home --exclude /home/bkup | |
#------------------------------- | |
# 設定ファイルバックアップ | |
#------------------------------- | |
tar czf $1/etc.tar.gz /etc | |
tar czf $1/var.tar.gz /var | |
#------------------------------- | |
# パッケージリストバックアップ | |
#------------------------------- | |
dpkg -l>$1/dpkg_list.txt | |
dpkg --get-selections "*">dpkg_list_selections.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment