ec2でファイルバックアップをする
ec2でログファイルのバックアップを取る機会があったのでそのメモ
バックアップしたファイルをs3に転送するのでs3cmdを使う
もしなかったらyumで入れてs3の初期設定をする
yum -y install s3cmd
s3cmd --configure
s3転送のため初期設定をします
Enter new values or accept defaults in brackets with Enter. Refer to user manual for detailed description of all options. Access key and Secret key are your identifiers for Amazon S3 Access Key : # アクセスキーを入力 Secret Key : # シークレットアクセスキーを入力 Encryption password : # 空でいいかも Path to GPG program [/usr/bin/gpg] : # 同じく空で Use HTTPS protocol [No] : # どちらかお好きな方を ... いろいろメッセージ ... Test access with supplied credentials? [Y/n] : # テストします。Yを入力しEnter Please wait... Success. Your access key and secret key worked fine :-) Now verifying that encryption works... Success. Encryption and decryption worked fine :-) Save settings? [y/N] : # セーブします。Yを入力しEnter
あとはバックアップを取りたいファイルを圧縮
tar cvzf backup-log.tar.gz /var/log/
圧縮が終わったらs3に転送します
s3cmd put backup-log.tar.gz s3://backet_name/backup-log.tar.gz
s3cmdでputはファイルを1つだけ転送するということ
その後にこちらの送りたいファイル名、次がs3の転送先です。
s3://バケット名/転送先のファイル名