[weewx-user] Re: how to backup and ftp sqlite db

2020-06-18 Thread Michael Sanphillipo
I've been using this script that I found and run it through sudo crontab it 
is named weewx_backup.sh. I know it's probably overkill but I run it every 
2 hours via cron. You will need to modify the backup location to match your 
liking.

#!/bin/bash





# A script to backup weewx configuration files to NAShostname (and SQLite 
data until MySQL service can be restored)





# While SQLite is being used, the service needs to be stopped before 
copying the data file to avoid corruption if the system is writing to the 
file during copy.


/etc/init.d/weewx stop


sleep 5





# Perform backup


rsync -r/etc/weewx  /home/pi/myNAS/etc


rsync -r/usr/share/weewx/user   /home/pi/myNAS/usr


rsync -r/var/lib/weewx  /home/pi/myNAS/var


rsync -r/etc/weewx  /media/pi/BACKUP/etc


rsync -r/usr/share/weewx/user   /media/pi/BACKUP/usr


rsync -r/var/lib/weewx  /media/pi/BACKUP/var




# Brinf weewx service backup.


/etc/init.d/weewx start



- show quoted text -


On Monday, June 15, 2020 at 9:02:32 AM UTC-4, Frank von Thienen wrote:
>
> Hi all,
>
> I have not much knowlwdge about shell scripting, so I have to ask.
> I need the follwoing action in a shell script, so I can do a cron out of 
> it.
> 1. stop weewx (/etc/init.d/weewx stop)
> 2. ftp the sqlite.db from it's directory to a given directory (outside 
> raspberry) with a time stamp (so time stamp should be added while 
> transferring via ftp
> 3. start weewx (/etc/init.d/weewx start)
>
> can anyone give me a helping hand.
>
> thanks
>
> Frank
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/238668c8-011e-42e8-86ef-7ffb5f9c1fe4o%40googlegroups.com.


[weewx-user] Re: how to backup and ftp sqlite db

2020-06-17 Thread gjr80
Hi,

You are probably going to need to do a little research. This or similar 
questions have come up a number of times over the years. You will find 
there are many solutions, some good, some better, but I suspect each being 
suitable in the users own circumstances. A few thoughts:

1. Unless you are using an extremely short archive interval there should be 
no need to stop WeeWX
2. A safe approach is to make a local copy of your database and then 
compress/transfer/rename or otherwise process this local copy
3. There can be a tendency to want to backup immediately after midnight, 
that is fine but the first archive period after midnight can be a busy 
period for WeeWX. Schedule your backup for the next archive period or later 
or once you are certain WeeWX has finished archiving/reporting etc.
4. What ever solution you adopt check that it works, I know of at least one 
user who thought they were backing up their sqlite db only to find when the 
crunch came their backup was corrupt/unreadable.

You might find this thread 

 
has some helpful information.

Gary

On Monday, 15 June 2020 23:02:32 UTC+10, Frank von Thienen wrote:
>
> Hi all,
>
> I have not much knowlwdge about shell scripting, so I have to ask.
> I need the follwoing action in a shell script, so I can do a cron out of 
> it.
> 1. stop weewx (/etc/init.d/weewx stop)
> 2. ftp the sqlite.db from it's directory to a given directory (outside 
> raspberry) with a time stamp (so time stamp should be added while 
> transferring via ftp
> 3. start weewx (/etc/init.d/weewx start)
>
> can anyone give me a helping hand.
>
> thanks
>
> Frank
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/a56af203-bf5d-4b4c-8c34-88f01d7e0bc6o%40googlegroups.com.