This is the old XigmaNAS forum in read only mode,
it will taken offline by the end of march 2021!



I like to aks Users and Admins to rewrite/take over important post from here into the new fresh main forum!
Its not possible for us to export from here and import it to the main forum!

Stas log transfer Rsync via mail

Synchronize files & directories to/from XigmaNAS with minimal data transfer.
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
adsoluzioni
NewUser
NewUser
Posts: 2
Joined: 01 Aug 2014 11:36
Status: Offline

Stas log transfer Rsync via mail

Post by adsoluzioni »

Hello everyone.
I configured rsync copy from NAS1(server) to NAS2 (client).
How can i create a stats log transfer (as below) to send me via mail?

I’d like a similar log:
Number of files: 211009
Number of files transferred: 410
Total file size: 903 GB
Total transferred file size: 9 GB
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 5864077
File list generation time: 23.204 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 5865513
Total bytes received: 1441

Someone, kindly, can me a step by step tutorial?
Thanks a lot…
P.s: i’m using the latest nas4free version

mcvillage
NewUser
NewUser
Posts: 12
Joined: 28 Feb 2014 00:03
Status: Offline

Re: Stas log transfer Rsync via mail

Post by mcvillage »

I was in your shoes a long time ago, and found help in the forums, I don't remember where, but I post the current script that I am using. Save it with a name and add a cron job to run it

NOTE: After having problems sending very big logs (and rsync logs can be very very big), I had to split it. If the log is bigger than MAXLINEAS lines It only sends the begining and the ending lines, enough to see if the rsync run went OK.

#!/bin/bash

PRINTF=/usr/bin/printf
MSMTP=/usr/local/bin/msmtp
MSMTPCONF=/var/etc/msmtp.conf
MAXLINEAS="40"

# change these variables!
FROM="original email dir" #--> The email dir that you set up in the config to send info emails
TO="destination email dir" #--> The email that will receive the logs
SUBJECT="Resumen backup rsync a nas01 `date +%Y-%m-%d`"
BODY="Resumen backup rsync a nas01 `date +%Y-%m-%d`\n"

for archivos in $(ls /mnt/backup/rsync_logs/*_`date +%Y-%m-%d`.txt) # --> /mnt/backup/rsync_logs/ is the place where I store the logs from rsync
do
# printf "$archivos\n"

lineas=$(wc -l < $archivos)
#echo $lineas

if [ "$lineas" -le "$MAXLINEAS" ];
then
#echo "Menor de 40 lineas se puede enviar entero"
BODY="$BODY\n\n$archivos\n\n$(cat $archivos)\n\n\n"

else
#echo "Mayor de 40 lineas -> truncar el fichero"
BODY="$BODY\n\n$archivos\n\n$(head -n 20 $archivos)\n\n.......\n\n$(tail -n 20 $archivos)\n\n\n"

fi

done

# send mail
$PRINTF "From:$FROM\nTo:$TO\nSubject:$SUBJECT\n\n$BODY" | $MSMTP --file=$MSMTPCONF -t

Hope it helps

adsoluzioni
NewUser
NewUser
Posts: 2
Joined: 01 Aug 2014 11:36
Status: Offline

Re: Stats log transfer Rsync via mail

Post by adsoluzioni »

I'm always me....

I'm trying to set up the rsync from cron.

i would want create a rsync line command to do the sync from nas1 to (nas2 in remote) and after send me only the log stats via mail.

Someone can give me the right command?

Thanks

mcvillage
NewUser
NewUser
Posts: 12
Joined: 28 Feb 2014 00:03
Status: Offline

Re: Stas log transfer Rsync via mail

Post by mcvillage »

There is no "right command". You have to set up the rsync from the gui, remember to configure rsync to create logs. After that you have to create a script file with the commands I wrote and after that in the cron gui (System -> Advanced -> Cron) you create a cron job and in the command you put the name and path of the script file and the time you want it to run. It's easier to do than to explain.

Post Reply

Return to “RSYNC”