SOURCE_ROOT="/來源目錄"
BACKUP_ROOT="/目的目錄"
echo "備份進行中..."
rsync -a $SOURCE_ROOT $BACKUP_ROOT
cd $BACKUP
git init
git add =A
git commit -am "Backup"
使用迴圈備份
#! /bin/bash
SOURCE_ROOT="/來源目錄"
BACKUP_ROOT="/目的目錄"
for i in `ls -1d *`; do
cd $i
rsync -a . $BACKUP_ROOT/$i
git init
git add -A
git commit -am "Backup."
cd ..
done