Search
Search titles only
By:
Search titles only
By:
Forums
New posts
Search forums
What's new
New posts
Latest activity
Feedback
View Statistics
Members
Current visitors
Buy Sell Trade
WTB
Log in
Register
Search
Search titles only
By:
Search titles only
By:
New posts
Search forums
Menu
Install the app
Install
Reply to thread
Forums
Technology
Home Automation & Networking
The Raspberry Pi Thread
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Marcus Fenix" data-source="post: 2297822" data-attributes="member: 38832"><p> <table style='width: 100%'><tr><td>#!/bin/bash<br /> <br /> TIMESTAMP=$(date +"%Y%m%d_%H%M%S")<br /> USB_PATH=/mnt/usb1 # [USER=14003]@raksrules[/USER] this is the path where dietpi-backup is saved by Pi.Change as per your drive name<br /> TGT_PATH=/mnt/usb2 # [USER=14003]@raksrules[/USER] this is the seondary HDD path where you want to manually copy dietpi-backup.Change as per your drive name<br /> # Sync dietpi-backup to a dated folder e.g. system_backup_20210711_031209 in secondary HDD<br /> MAX_BACKUP_DAYS=30<br /> G_USER_UNPUT=0<br /> #Run dietpi-backup utility<br /> G_INTERACTIVE=0 /boot/dietpi/dietpi-backup 1<br /> #Copy the fresh dietpi-backup to seondary HDD path<br /> rsync -r --progress "${USB_PATH}/dietpi-backup" "${TGT_PATH}/system_backup_${TIMESTAMP}"<br /> #Delete any folders having names like system_backup_* older than 30 days<br /> find ${TGT_PATH} -mindepth 1 -type d -name "system_backup_*" -mtime +${MAX_BACKUP_DAYS} | while read d;<br /> do<br /> echo "Deleting $d"<br /> rm -Rf $d<br /> done<br /> #dietpi package updates<br /> sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'</td></tr></table><p></p><p>Save this script as backup.sh. Change the USB_PATH and TGT_PATH variables and you are good to to. Run the script after attaching you secondary HDD and it will do all the things you need.</p><p></p><p>Copying the code here threw off the formatting a bit. It should look like this in the while loop.</p></blockquote><p></p>
[QUOTE="Marcus Fenix, post: 2297822, member: 38832"] [TABLE] [TR] [TD]#!/bin/bash TIMESTAMP=$(date +"%Y%m%d_%H%M%S") USB_PATH=/mnt/usb1 # [USER=14003]@raksrules[/USER] this is the path where dietpi-backup is saved by Pi.Change as per your drive name TGT_PATH=/mnt/usb2 # [USER=14003]@raksrules[/USER] this is the seondary HDD path where you want to manually copy dietpi-backup.Change as per your drive name # Sync dietpi-backup to a dated folder e.g. system_backup_20210711_031209 in secondary HDD MAX_BACKUP_DAYS=30 G_USER_UNPUT=0 #Run dietpi-backup utility G_INTERACTIVE=0 /boot/dietpi/dietpi-backup 1 #Copy the fresh dietpi-backup to seondary HDD path rsync -r --progress "${USB_PATH}/dietpi-backup" "${TGT_PATH}/system_backup_${TIMESTAMP}" #Delete any folders having names like system_backup_* older than 30 days find ${TGT_PATH} -mindepth 1 -type d -name "system_backup_*" -mtime +${MAX_BACKUP_DAYS} | while read d; do echo "Deleting $d" rm -Rf $d done #dietpi package updates sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'[/TD] [/TR] [/TABLE] Save this script as backup.sh. Change the USB_PATH and TGT_PATH variables and you are good to to. Run the script after attaching you secondary HDD and it will do all the things you need. Copying the code here threw off the formatting a bit. It should look like this in the while loop. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Technology
Home Automation & Networking
The Raspberry Pi Thread
Top
Bottom