はじめに
- バックアップリストア改廃を復習してみたときのメモです
- 5W1Hを意識して漏れなく設計します
一覧
- 取得元
- サービス
- 項目
- インスタンス
- バックアップ
- 方式
- トリガ
- タイミング
- リストア
- 方式
- 改廃(取得元)
- 方式
- トリガ
- ローカル保存世代数
- 改廃(バックアップ先)
- 方式
- トリガ
- タイミング
- ローカル保存世代数
Host own-dev-app01 HostName 3.14.15.92 Port 22 User ec2-user IdentityFile ~/.ssh/own-dev-key.pem IdentitiesOnly yes TCPKeepAlive yes
# 事前にbrewのインストール # echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc brew install vim
~/.vimrc
"---------------------------------------- " setting "---------------------------------------- "文字コードをUFT-8に設定 set fenc=utf-8 " バックアップファイルを作らない set nobackup " スワップファイルを作らない set noswapfile " 編集中のファイルが変更されたら自動で読み直す set autoread " バッファが編集中でもその他のファイルを開けるように set hidden " 入力中のコマンドをステータスに表示する set showcmd "---------------------------------------- " 見た目系 "---------------------------------------- " 行番号を表示 set number " タイトルを表示 set title " 現在の行を強調表示 set cursorline " 行末の1文字先までカーソルを移動できるように set virtualedit=onemore " 括弧入力時の対応する括弧を表示 set showmatch " ステータスラインを常に表示 set laststatus=2 " コマンドラインの補完 set wildmode=list:longest " 折り返し時に表示行単位での移動できるようにする nnoremap j gj nnoremap k gk " シンタックスハイライトの有効化 syntax enable " コメントの色を水色 hi Comment ctermfg=3 "---------------------------------------- " Tab系 "---------------------------------------- " 不可視文字を可視化(タブが「▸-」と表示される) set list listchars=tab:\▸\- " Tab文字を半角スペースにする set expandtab " 行頭以外のTab文字の表示幅(スペースいくつ分) set tabstop=4 " 行頭でのTab文字の表示幅 set shiftwidth=4 "---------------------------------------- " 検索系 "---------------------------------------- " 検索文字列が小文字の場合は大文字小文字を区別なく検索する set ignorecase " 検索文字列に大文字が含まれている場合は区別して検索する set smartcase " 検索文字列入力時に順次対象文字列にヒットさせる set incsearch " 検索時に最後まで行ったら最初に戻る set wrapscan " 検索語をハイライト表示 set hlsearch
$ brew install pyenv $ pyenv install 3.9.2 $ pyenv global 3.9.2 $ mkdir -p ~/opt/python_env $ cd python_env; pwd # 上記でセットアップしたpythonを利用 # /Users/<USER>/.pyenv/versions/3.9.2/bin/python -V $ python -m venv py392env $ source /Users/username/opt/python_env/py392env/bin/activate $ pip install numpy $ pip install Pillow $ pip install jupyter $ jupyter notebook --notebook-dir=~/pj/ & # Tabnineのインストール
# python仮想環境activate後に実施 $ pip install xonsh $ pip install gnureadline $ brew install bash-completion2 $ brew install peco $ which xonsh ->iTerm各プロファイルのCommandを上記パスに修正
# python # source-bash source /Users/username/opt/python_env/py364env/bin/activate # path $PATH.append("/usr/local/bin/") # prompt $PROMPT = "{INTENSE_RED}{user}{INTENSE_GREEN}@{INTENSE_BLUE}{hostname}{INTENSE_YELLOW} [ {cwd} ] {GREEN}$ " # tab $INDENT = " " # completion $COMPLETIONS_CONFIRM = True # ls $LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30" # alias aliases["lt"] = "ls -ltr" aliases["la"] = "ls -la" aliases["ll"] = "ls -l" # complement command and ssh import os import json from collections import OrderedDict from operator import itemgetter from prompt_toolkit.keys import Keys from prompt_toolkit.filters import (Condition, IsMultiline, HasSelection, ViInsertMode) from prompt_toolkit import print_formatted_text from prompt_toolkit.styles import Style @events.on_ptk_create def custom_keybindings(bindings, **kw): # ctrl+rで過去の実行コマンドをpeco @bindings.add('c-r') def select_history(event): sess_history = $(history).split('\n') hist = _get_history(sess_history) selected = $(echo @(hist) | peco) event.current_buffer.insert_text(selected.strip()) # ctrl+sでssh_config内のhost先をpeco @bindings.add('c-s') def select_ssh(event): hosts = _get_host(True) selected = $(echo @(hosts) | peco) if selected: event.current_buffer.insert_text('ssh ' + selected.strip().split(', ')[0]) # ctrl+fで今いるディレクトリのfileをpeco @bindings.add('c-f') def select_file(event): r = lambda x: './'+x if os.path.isdir(x) else x files = '\n'.join([r(x.split(' ')[-1]) for x in $(ls -l).split('\n')]) selected = $(echo @(files) | peco) event.current_buffer.insert_text(selected.strip()) inquirer_style = Style.from_dict({ 'qa': '#5F819D', 'qu': '#FF9D00', 'dp': '#000' }) def _get_history(session_history=None, return_list=False): hist_dir = __xonsh__.env['XONSH_DATA_DIR'] files = [ os.path.join(hist_dir,f) for f in os.listdir(hist_dir) if f.startswith('xonsh-') and f.endswith('.json') ] file_hist = [] for f in files: try: file_hist.append(json.load(open(f))['data']['cmds']) except: pass cmds = [ ( c['inp'].replace('\n', ''), c['ts'][0] ) for cmds in file_hist for c in cmds if c] cmds.sort(key=itemgetter(1)) cmds = [ c[0] for c in cmds[::-1] ] if session_history: cmds.extend(session_history) # dedupe zip_with_dummy = list(zip(cmds, [0] * len(cmds)))[::-1] cmds = list(OrderedDict(zip_with_dummy).keys())[::-1] cmds = reversed(cmds) if return_list: return cmds else: return '\n'.join(cmds) def _get_host(color=False): all_text = '' text = '' for x in $(cat ~/.ssh/config).split('\n'): if 'LocalForward' in x: text += ', ' + x.strip().split(' ')[1] if 'HostName' in x: text += ', ' + x.strip().split(' ')[1] elif 'Host ' in x: if text!='': all_text += text + '\n' text = x.split(' ')[1] all_text += text + '\n' if not color: all_d = [] for x in all_text.split('\n'): for i,y in enumerate(x.split(', ')): if i==0: all_d.append(('class:qu', y)) if i==1: all_d.append(('', ', ')) all_d.append(('class:qa', y)) if len(x.split(', '))==2: all_d.append(('','\n')) if i==2: all_d.append(('', ', ')) all_d.append(('class:qp', y)) all_d.append(('','\n')) print_formatted_text(FormattedText(all_d), style=inquirer_style) return return all_text aliases['host']=_get_host
キーボードショートカット
// Place your key bindings in this file to overwrite the defaults [ { "key": "cmd+t", "command": "workbench.action.files.newUntitledFile" }, { "key": "cmd+q", "command": "workbench.action.closeActiveEditor" }, { "key": "cmd+h", "command": "editor.action.startFindReplaceAction" }, ]
use_tag_as_stream true
でも良い<source> @type tail path /var/log/httpd/access_log pos_file /var/log/td-agent/httpd.access.log.pos format apache tag td.apache.access </source> <match td.apache.**> @type cloudwatch_logs region ap-northeast-1 auto_create_stream true log_stream_name ${hostname} log_group_name ${tag} retention_in_days 8 flush_at_shutdown true </match> <match td.apache.**> @type s3 s3_region ap-northeast-1 s3_enpoint s3-ap-northeast-1.amazonaws.com s3_bucket s3-bucket-log path ec2/ time_slice_format ${hostname}/${tag}/${tag}-%Y%m%d%H flush_at_shutdown true </match>
<source> @type tail </source> <match td.syslog.**> @copy <store> @type cloudwatch_logs </store> <store> @type s3 </store> <store> @type grepcounter </store> </match> <filter slack.td.syslog.**> @type record_transformer </filter> ... <match slack.**> @type slack </match>
kinesis firehose delivery stream
とそのIAMロールを作る + CloudWatchの subscription filter
とそのIAMロールを作るlogrotate -dv /etc/logrotate.conf
/var/log/sample/access.log { # 対象のログファイル ifempty # ログファイルが空でもローテーションする daily # 毎日ローテートする # dataext # dailyと組み合わせ、元のファイル名 + -YYYYMMDD のファイル名で生成 dateformat .%Y%m%d # dateフォーマットを任意のものに変更する missingok # ログファイルがなくてもエラーを出さない compress # 圧縮する delaycompress # ログの圧縮作業を次回のローテーション時まで遅らせる。compressと共に指定 rotate 10 # 10世代分古いログを残す # create 0644 fuga fuga # ローテーションを行った後、代わりに空の新規ログファイルを作る。権限・グループ・ユーザを指定可能 postrotate # ローテート後にsyslogを再起動 /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true endscript }