L'intento di questa guida è di mostrare come utilizzare la skin del report RSYNC di Weewx per eseguire il backup del database. Può ovviamente essere estesa tramite ulteriori voci per eseguire altri trasferimenti di file, ma sarebbe meglio mantenerla semplice e non sovraccaricare Weewx (vedere la parte finale della guida se questo suggerimento ti interessa).
La sincronizzazione del tuo database SQLite è semplice, quest'azione può essere eseguita spesso senza sovraccaricare Weewx.
USANDOLO INSIEME A STDREPORT
Il ciclo di report in Weewx inizia solo quando tutte le scritture nel database sono terminate, ciò fornisce una certa sicurezza che qualsiasi copia del database presa in quel momento sarà valida.
Questo metodo si basa sulla capacità di utilizzare più istanze di una skin semplicemente assegnando loro il proprio nome [[Sezione]] nel file weewx.conf o nel file skin.conf
Il più semplice: usare weewx.conf
[[RSYNCSQL]] skin = Rsync
Quindi ridefiniamo HTML_ROOT (questo influisce solo su questa skin e solo quando viene eseguito) per puntare al database locale:
[[RSYNCSQL]] skin = Rsync HTML_ROOT = /var/lib/weewx
Quindi aggiungi gli altri requisiti per avviarlo ed eseguirlo:
[[RSYNCSQL]] skin = Rsync HTML_ROOT = /var/lib/weewx server = 192.168.0.100 user = graybeard path = /home/graybeard/rsynsql-weewx1
Infine, aggiungi una stanza report_time di tua scelta (o no se vuoi una copia in sequenza). Sarebbe meglio controllare il tuo archive_interval in weewx.conf e impostare questo intervallo più lungo di quello.
Un'alternativa: usare skin.conf
In alternativa, trasferisci tutto (tranne la variabile HTML_ROOT) in un file skin.conf e in questo modo puoi apportare modifiche alla tua configurazione mentre Weewx è in esecuzione. Il file weewx.conf ha la precedenza sui file skin.conf, quindi in weewx.conf commenta i valori che non vuoi che siano permanenti (che richiedebbero un riavvio di Weewx per l'azione) e inseriscili nel file skin.conf.
In altre parole, qualsiasi argomento che è univoco per skin.conf verrà letto e azionato in ogni ciclo di report. Se esiste anche in weewx.conf, quel valore ha la priorità e può essere letto (azionato) solo riavviando Weewx. E HTML_ROOT è esclusivo del file weewx.conf
[[RSYNCSQL]] skin = Rsyncsql HTML_ROOT = /var/lib/weewx # If it's local, an ip address is fine for the server #server = 192.168.0.100 # account that has password less access to the server #user = graybeard # where to put it all, don't nest too deeply unless you create the tree first #path = /home/graybeard/rsyncsql-weewx1 # every 20 minutes, run this report # report_timing = '*/20 * * * *' # add the default delete = 0
Notare la modifica alla prima riga skin = Rsync , ora puntiamo a skin = Rsyncsql.
Quindi dobbiamo crearlo...
skin cd cp -r Rsync Rsyncsql/
e poi modificalo, il file skins/Rsyncsql/skin.conf, per aggiungere quanto segue dopo i commenti in alto...
HTML_ROOT = /var/lib/weewx # If it's local, an ip address is fine for the server server = 192.168.0.100 # account that has password less access to the server user = graybeard # where to put it all, don't nest too deeply unless you create the tree first path = /home/graybeard/rsyncsql-weewx-skin # every 20 minutes, run this report report_timing = '*/20 * * * *' # add the default delete = 0
Crea l'accesso senza password
Infine crea l'accesso senza password per l'utente remoto, dalla root locale (l'account Weewx è in esecuzione come e per la maggior parte degli utenti che saranno root)
Quando ti viene chiesta la passphrase, premi invio. Se sei preoccupato per la sicurezza, considera l'esecuzione di Weewx con un utente meno privilegiato: vedi Eseguire Weewx come utente non root
Esegui questo (usa il tuo account!)...
sudo -i ssh-keygen ssh-copy-id -i ~/.ssh/id_rsa.pub graybeard@192.168.0.100 ssh 'graybeard@192.168.0.100'
e vedrai qualcosa del genere (i nomi sono stati cambiati per privacy)...
READ WRITE : root@raspberrypi:~# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: e6:54:4e:43:b1:72:fb:8d:5f:3f:8c:d6:b4:2a:8b:fa root@raspberrypi The key's randomart image is: +---[RSA 2048]----+ | o. | | . . | | . * | | * o | | S o | | + . o . | | . o * o| | .. + *.| | .oE .+.o o| +-----------------+ READ WRITE : root@raspberrypi:~# ssh-copy-id -i ~/.ssh/id_rsa.pub graybeard@192.168.0.100 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys graybeard@192.168.0.100's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'graybeard@192.168.0.100'" and check to make sure that only the key(s) you wanted were added. READ WRITE : root@raspberrypi:~# ssh 'graybeard@192.168.0.100' The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. You have new mail. Last login: Tue Feb 14 08:56:07 2017 from 192.168.0.215 xterm graybeard@whitebeard:~ 09:31 AM $ logout Connection to 192.168.0.100 closed.
Provalo
Riavvia weewx e controlla i tuoi log
/etc/init.d/weewx restart && tail -f /var/log/syslog
ESPANDERE IL CONCETTO
Visita la documentazione di Weewx, crea e popola una nuova [[Sezione]], imposta un periodo di report_timing ragionevole e tieni d'occhio i tuoi log. Ciò che vogliamo sottolineare in particolare sono i tempi di RSYNC che vengono visualizzati lì. Le decisioni vanno prese sulla base di ciò: il tempo per l'esecuzione dei tuoi rapporti.