Steve2Q
Posts: 8
Joined: Wed Jul 02, 2014 6:35 pm

Question on zipping and uploading a file

Sun Oct 14, 2018 1:07 am

Hi, I am not sure if this belongs in the "advanced" forum. I would like an opinion if the following is the best way to do what I intend. That is: once a day on an odd minute, zip and upload a file from my raspberry to my web server. The file is a SQlite file (xxx.sdb) which is updated by a program running on the pi every 2 even minutes. Then, delete the zipped file on the pi to save disk space, and send me an email that the process was successful.

Here is the code for the process called /home/bin/xxxbackup: The reason I make a copy of xxx.sdb before zipping is I don't want to take a chance on corrupting the file. I found this many months ago on a web site, but I am not sure if this is the best way to do it

#!/bin/bash
#This script zips and backs up to a website
export TERM=${TERM:-dumb} #keeps from throwing "TERM environment variable not set" error
clear

echo "Backing up xxx.sdb"

cd/home/xxx/archive
sudo cp xxx.sdb xxxpi2.cpy
sudo gzip xxxpi2.cpy
sudo lftp -e 'put /home/xxx/archive/xxxpi2.cpy.gz: bye' u
zzz,zzzzftp.zzzabcd.org
sudo rm xxxpi2.cpy.gz

echo "Done - xxxpi2.sdb zipped and uploaded to zzzabcd.org


This is the cron:

MAILTO= [email protected]

59 23 * * * /home/bin/./xxxbackup

What are your thoughts?

Thanks ...Steve

Return to “Advanced users”

Who is online

Users browsing this forum: Andyroo and 8 guests