Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup sd card partitions
#!/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
You can’t perform that action at this time.