|
#!/bin/sh |
|
|
|
####################################################### |
|
# LightroomでのRAW画像のインポートフォルダ: |
|
# ~/Pictures/Raw_Images |
|
# Lightroomカタログのバックアップフォルダ: |
|
# ~/Pictures/Lightroom/Catalog_Backups/private |
|
# |
|
# 上記のようにあらかじめ設定しています。 |
|
# |
|
# 今年分しかバックアップ対象としません。 |
|
####################################################### |
|
|
|
set -e |
|
|
|
PATH_TO_RAW_IMAGE=~/Pictures/Raw_Images |
|
PATH_TO_LIGHTROOM_CATALOG=~/Pictures/Lightroom/Catalog_Backups/private |
|
PATH_TO_BACKUP_RAW_IMAGE=/Volumes/Data/Pictures/Raw_Images |
|
PATH_TO_BACKUP_LIGHTROOM_CATALOG=/Volumes/Data/Pictures/Lightroom/Catalog_Backups/private |
|
CURRENT_YEAR=`date +"%Y"` |
|
BACKUP_RAW_LIST=backup_raw_list.txt |
|
BACKUP_CATALOG_LIST=backup_catalog_list.txt |
|
|
|
flg=0 |
|
|
|
rm -f $BACKUP_RAW_LIST |
|
rm -f $BACKUP_CATALOG_LIST |
|
|
|
echo "[Backup photography-related data]" |
|
|
|
diff "${PATH_TO_RAW_IMAGE}/${CURRENT_YEAR}" "${PATH_TO_BACKUP_RAW_IMAGE}/${CURRENT_YEAR}" | \ |
|
grep "Only in ${HOME}" | grep -v ".DS_Store" | awk '{print $4}' > $BACKUP_RAW_LIST |
|
diff "${PATH_TO_LIGHTROOM_CATALOG}/" "${PATH_TO_BACKUP_LIGHTROOM_CATALOG}" | \ |
|
grep "Only in ${HOME}" | grep -v ".DS_Store" | awk '{print $4 " " $5}' > \ |
|
$BACKUP_CATALOG_LIST |
|
|
|
echo "### Raw images ###" |
|
if [ -s $BACKUP_RAW_LIST ]; then |
|
cat $BACKUP_RAW_LIST |
|
else |
|
echo "No changes" |
|
flg=$((flg+1)) |
|
fi |
|
echo "### Catalog ###" |
|
if [ -s $BACKUP_CATALOG_LIST ]; then |
|
cat $BACKUP_CATALOG_LIST |
|
else |
|
echo "No changes" |
|
flg=$((flg+1)) |
|
fi |
|
|
|
if [ $flg -eq 2 ]; then |
|
exit |
|
fi |
|
|
|
echo "Would you like to backup raw image and Lightroom catalog?" |
|
echo "Type Y to backup photography-related data: \c" |
|
read line |
|
if [ "$line" = Y ] || [ "$line" = y ]; then |
|
while read line |
|
do |
|
echo "[Raw images] Copying $line" |
|
cp -R "${PATH_TO_RAW_IMAGE}/$CURRENT_YEAR/$line" "${PATH_TO_BACKUP_RAW_IMAGE}/$CURRENT_YEAR" |
|
done < $BACKUP_RAW_LIST |
|
while read line |
|
do |
|
echo "[Catalog] Copying $line" |
|
cp -R "${PATH_TO_LIGHTROOM_CATALOG}/$line" "${PATH_TO_BACKUP_LIGHTROOM_CATALOG}" |
|
done < $BACKUP_CATALOG_LIST |
|
else exit |
|
fi |