Benutzer-Werkzeuge

Webseiten-Werkzeuge


vu:aufnahmen_von_interner_hdd_verschieben

Aufnahmen von interner HDD verschieben

Wenn die Festplatte zu klein wird können mit diesem Skript die Aufnahmen z.B. auf ein NAS verschoben werden.

move.sh
#!/bin/bash
 
############################################################################################################################################
# This script is designed for Vu+ sat receivers with VTI image.
# The idea is to "move" recordings from a local harddisk to a NAS (e.g. Synology DiskStation)
# It is possible make recordings directly to the NAS.
# But in case of no availability or heavy network or NAS load the quality of recordings might be bad.
# So the recordings are always local and will be "moved" to the NAS once per day to free harddisk space.
# The NAS is connected with NFS to the receiver.
# I decided to use the copy command instead of the move command as I recognised data loss (maybe because of protected .ts and .eit files).
# After the copy command I check if the .ts file is existing (the other files are not so important) before I delete the source files.
# Recordings that are marked for deletion are ignored.
#
# Author: R. Wudernitz
# Date: 2018-03-11, 2018-03-19
#
# Please note: I am no programmer. I created this script with help of DuckDuckGo and by try and error. USE IT AT YOUR OWN RISK !!!
############################################################################################################################################
 
 
##### make your changes here according to your setup
foldersource="/media/hdd/movie/"			# source movie folder (should be the absolute path, must end with /)
folderdest="/media/net/autonet/DISKSTATION/"		# destination folder (should be the absolute path, must end with /)
age=1							# age of the source file in days (0 = yesterday, 1 = day before yesterday, etc.)
 
 
################## main routine (nothing to change below) ##########################
if [ -d "$foldersource" ] && [ -d "$folderdest" ]; then						# check if both folders are existing
	for filets in $foldersource*.ts ; do								# search for ts files
		fname=$(basename "$filets");								# extract file name
		if ! [ -f "$filets.del" ]; then								# check if movie is marked as deleted (deleted not moved)
			fdate=${fname%%\ *}								# get the recording date from the file name
			cdate=$(date "+%Y%m%d")								# current system date
			ddif=$(($cdate - $fdate))							# calculate a date difference
 
			if [ $ddif -gt $age ]; then							# when older than $age days
				copyf=${filets%.*}							# extract the filename without extension
				if [ -d "$foldersource" ] && [ -d "$folderdest" ]; then		# check again if both folders are existing
					cp "$copyf".* "$folderdest"					# copy files from source to destination
					if [ -f "$folderdest$fname" ]; then				# check if file is copied correctly
						rm "${copyf}".*						# remove files from source
					fi
				fi
			fi
		fi
	done
fi
vu/aufnahmen_von_interner_hdd_verschieben.txt · Zuletzt geändert: 2021/02/20 10:13 von dokuwikiadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki