Skip to content

Instantly share code, notes, and snippets.

@the-eric-kwok
Last active January 19, 2018 06:12
Show Gist options
  • Save the-eric-kwok/b30931438382e416fd5a184bdcec08d8 to your computer and use it in GitHub Desktop.
Save the-eric-kwok/b30931438382e416fd5a184bdcec08d8 to your computer and use it in GitHub Desktop.
auto backup spigot dir
#!/bin/bash
DATE=`date '+%F'` #获取当前日期
DEL-DATE="30" #自动删除30天以前的备份
BACKUP_DIR="./share/spigot_backup" #备份目录
tar -zcvf "$DATE-spigot.tar.gz" ~/spigot
if [ ! -d "$BACKUP_DIR" ]; then
mkdir "$BACKUP_DIR"
fi
mv *-spigot.tar.gz "$BACKUP_DIR"
find "$BACKUP_DIR" -mtime "+$DEL-DATE" -exec "rm {} \"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment