#!/bin/bash
now=$(date +"%d-%m-%Y")
#device path that you want to get a image of it
device="/dev/mmcblk0"
#a folder path which isn't a system drive
path="/mnt/sata/backup"
rsyncfolder="systembackup-$now"
filename="backup.$now.img.gz"
filesize=$(stat -c%s "$path/$filename")
foldersize=$(du -hs "$path/$rsyncfolder")
echo "Backing up $device device to $path/$filename file, please wait..."
dd if=$device conv=sync,noerror bs=64K | gzip -c -9 > $path/$filename
echo "Size of $filename = $filesizebytes."
echo "Device Backup Completed."
echo "System Backup Starting to $path/$rsyncfolder"
mkdir -p $path/$rsyncfolder
rsync -aAXv --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / $path/$rsyncfolder
echo "System Backup Completed with size of $foldersize."
Change device and path parameters as you like and make a cron job for it and take care your files.
Bir yanıt yazın