There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.
Accounts which solely post advertisements, or persistently post them may be terminated.
luthis OP , 9 months ago The script takes the drives as arguments: <span style="color:#323232;">$ pwd </span><span style="color:#323232;">/usr/lib/systemd/system </span><span style="color:#323232;">$ cat drive_backup.service </span><span style="color:#323232;">[Unit] </span><span style="color:#323232;">Description=backup fdisk + e2image </span><span style="color:#323232;">Wants=drive_backup.timer </span><span style="color:#323232;"> </span><span style="color:#323232;">[Service] </span><span style="color:#323232;">Type=oneshot </span><span style="color:#323232;">ExecStart=/usr/bin/backup_meta_data.sh /dev/sdc1 /dev/sdb1 </span><span style="color:#323232;"> </span><span style="color:#323232;">[Install] </span><span style="color:#323232;">WantedBy=multi-user.target </span> Set to run at 3:40am every day, but probably could be once weekly really. <span style="color:#323232;">$ cat drive_backup.timer </span><span style="color:#323232;">[Unit] </span><span style="color:#323232;">Description=timer to run drive backup </span><span style="color:#323232;">Requires=drive_backup.service </span><span style="color:#323232;"> </span><span style="color:#323232;">[Timer] </span><span style="color:#323232;">Unit=drive_backup.service </span><span style="color:#323232;">OnCalendar=*-*-* 03:40:00 </span><span style="color:#323232;"> </span><span style="color:#323232;">[Install] </span><span style="color:#323232;">WantedBy=timers.target </span> Should be fairly self-explanatory. <span style="color:#323232;">$ cat /usr/bin/backup_meta_data.sh </span><span style="color:#323232;">#!/bin/bash </span><span style="color:#323232;"> </span><span style="color:#323232;">working_dir=/home/st/drive_recovery/working </span><span style="color:#323232;">backup_dir=/home/st/drive_recovery </span><span style="color:#323232;">backup_date=$(date +%Y%m%d-%H%M) </span><span style="color:#323232;"> </span><span style="color:#323232;">mkdir -p $working_dir </span><span style="color:#323232;"> </span><span style="color:#323232;">sudo fdisk -x > $working_dir/$backup_date.fdisk </span><span style="color:#323232;"> </span><span style="color:#323232;">for var in "$@" </span><span style="color:#323232;">do </span><span style="color:#323232;"> clean=$(echo $var | sed 's;/;-;g') </span><span style="color:#323232;"> sudo e2image $var $working_dir/$backup_date.$clean </span><span style="color:#323232;">done </span><span style="color:#323232;"> </span><span style="color:#323232;">sudo 7z a $backup_dir/$backup_date.archive $working_dir/"$backup_date"* </span><span style="color:#323232;">sudo rm $working_dir/"$backup_date"* </span>
The script takes the drives as arguments:
<span style="color:#323232;">$ pwd </span><span style="color:#323232;">/usr/lib/systemd/system </span><span style="color:#323232;">$ cat drive_backup.service </span><span style="color:#323232;">[Unit] </span><span style="color:#323232;">Description=backup fdisk + e2image </span><span style="color:#323232;">Wants=drive_backup.timer </span><span style="color:#323232;"> </span><span style="color:#323232;">[Service] </span><span style="color:#323232;">Type=oneshot </span><span style="color:#323232;">ExecStart=/usr/bin/backup_meta_data.sh /dev/sdc1 /dev/sdb1 </span><span style="color:#323232;"> </span><span style="color:#323232;">[Install] </span><span style="color:#323232;">WantedBy=multi-user.target </span>
Set to run at 3:40am every day, but probably could be once weekly really.
<span style="color:#323232;">$ cat drive_backup.timer </span><span style="color:#323232;">[Unit] </span><span style="color:#323232;">Description=timer to run drive backup </span><span style="color:#323232;">Requires=drive_backup.service </span><span style="color:#323232;"> </span><span style="color:#323232;">[Timer] </span><span style="color:#323232;">Unit=drive_backup.service </span><span style="color:#323232;">OnCalendar=*-*-* 03:40:00 </span><span style="color:#323232;"> </span><span style="color:#323232;">[Install] </span><span style="color:#323232;">WantedBy=timers.target </span>
Should be fairly self-explanatory.
<span style="color:#323232;">$ cat /usr/bin/backup_meta_data.sh </span><span style="color:#323232;">#!/bin/bash </span><span style="color:#323232;"> </span><span style="color:#323232;">working_dir=/home/st/drive_recovery/working </span><span style="color:#323232;">backup_dir=/home/st/drive_recovery </span><span style="color:#323232;">backup_date=$(date +%Y%m%d-%H%M) </span><span style="color:#323232;"> </span><span style="color:#323232;">mkdir -p $working_dir </span><span style="color:#323232;"> </span><span style="color:#323232;">sudo fdisk -x > $working_dir/$backup_date.fdisk </span><span style="color:#323232;"> </span><span style="color:#323232;">for var in "$@" </span><span style="color:#323232;">do </span><span style="color:#323232;"> clean=$(echo $var | sed 's;/;-;g') </span><span style="color:#323232;"> sudo e2image $var $working_dir/$backup_date.$clean </span><span style="color:#323232;">done </span><span style="color:#323232;"> </span><span style="color:#323232;">sudo 7z a $backup_dir/$backup_date.archive $working_dir/"$backup_date"* </span><span style="color:#323232;">sudo rm $working_dir/"$backup_date"* </span>