Skip to content

Instantly share code, notes, and snippets.

@taka3110
Created September 27, 2018 05:07
Show Gist options
  • Save taka3110/934ebef86450c827981d60c603e3fb1a to your computer and use it in GitHub Desktop.
Save taka3110/934ebef86450c827981d60c603e3fb1a to your computer and use it in GitHub Desktop.
システムバックアップサンプル
#!/bin/bash
########################
###### Base info
########################
NEWDATE=`/bin/date --date='today' +%Y%m%d`
DELDATE=`/bin/date --date='7 days ago' +%Y%m%d`
BACKUPDIR=/your/path
LIST="/tmp/list$$.txt"
########################
#EOFからEOFに挟んでいるエリアがバックアップ対象
cat > "$LIST" <<EOF
/etc
/root/.ssh
/var/spool/cron
EOF
tar cvfzT $BACKUPDIR/`/bin/hostname`_backup.$NEWDATE.tgz "$LIST"
rm -f "$LIST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment