Created
October 8, 2018 23:28
-
-
Save reinforce-lab/7f0b0dd16e421f91a8774dbbe8a5ed94 to your computer and use it in GitHub Desktop.
MacでS3に定期バックアップするスクリプト
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/sh | |
# account <YOUR_MAIL_ADDRESS> | |
# aws AIM 役割のユーザアカウントを作る <BAKET_NAME> | |
# aws configure --profile backup, CSVダウンロードしたアクセスキーとシークレットキーを backup として登録 | |
# バージニア北部、us-east-1 | |
# launchctrlに設定。設定ファイルの書式は man launchd.plist | |
# launchctl load <YOUR_DOMAIN_IN_REVERSE>.aws-s3-backup.plist | |
# launchctl list | |
# plistファイルは、~/Library/LaunchAgents においておく。 | |
# launchctl のplistファイル例。週に2回、午前1時にバックアップを開始する。 | |
#<?xml version="1.0" encoding="UTF-8"?> | |
#<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
#<plist version="1.0"> | |
#<dict> | |
# <key>Label</key> | |
# <string><YOUR_DOMAIN_IN_REVERSE>.aws-s3-backup</string> | |
# <key>Program</key> | |
# <string><PATH_TO_SHELLSCRIPT>/backup.sh</string> | |
# <key>ProgramArguments</key> | |
# <array> | |
# <string></string> | |
# </array> | |
# <key>StartCalendarInterval</key> | |
# <array> | |
# <dict> | |
# <key>Minute</key> | |
# <integer>0</integer> | |
# <key>Hour</key> | |
# <integer>1</integer> | |
# <key>Weekday</key> | |
# <integer>2</integer> | |
# </dict> | |
# <dict> | |
# <key>Minute</key> | |
# <integer>0</integer> | |
# <key>Hour</key> | |
# <integer>1</integer> | |
# <key>Weekday</key> | |
# <integer>6</integer> | |
# </dict> | |
# </array> | |
# <key>RunAtLoad</key> | |
# <false/> | |
# </dict> | |
# </plist> | |
<PATH_TO_AWS>/aws s3 sync --exact-timestamps --delete <BACKUP_LOCAL_FOLDER> s3://<BAKET_NAME>/<FOLDER_NAME> --storage-class STANDARD_IA --profile backup --region us-east-1 --exclude '*.DS_Store' | |
# バックアップしたいフォルダを、上のフォーマットで並べる。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment