-
-
Save bonelifer/fc2dbc29da24f49d0c2b to your computer and use it in GitHub Desktop.
Backup sd card partitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo deleting local files older than a week... | |
find /media/data/backup/* -mtime +7 -type f -delete | |
echo backuping up /dev/mmcblk0p1... | |
if [ ! -f /media/data/backup/$(date +%Y%m%d)_mmcblk0p1.img ]; then | |
dd if=/dev/mmcblk0p1 of=/media/data/backup/$(date +%Y%m%d)_mmcblk0p1.img | |
fi | |
echo backuping up /dev/mmcblk0p2... | |
if [ ! -f /media/data/backup/$(date +%Y%m%d)_mmcblk0p2.img ]; then | |
dd if=/dev/mmcblk0p2 of=/media/data/backup/$(date +%Y%m%d)_mmcblk0p2.img | |
fi | |
echo deleting remote files older than a month... | |
find /mnt/public/Backup/osmc/201*.img -mtime +10 -type f -delete | |
echo copying mmcblk0p1.img to network... | |
if [ -f /media/data/backup/$(date +%Y%m%d)_mmcblk0p1.img ]; then | |
cp /media/data/backup/$(date +%Y%m%d)_mmcblk0p1.img /mnt/public/Backup/osmc/ | |
fi | |
echo copying mmcblk0p2.img to network... | |
if [ -f /media/data/backup/$(date +%Y%m%d)_mmcblk0p2.img ]; then | |
cp /media/data/backup/$(date +%Y%m%d)_mmcblk0p2.img /mnt/public/Backup/osmc/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment