Ubuntu: How to upload sqlite3 database to webserver? [on hold]


I am very new to this. There is tuptime.db file which has records of uptime in my computer(local server). How can I upload it to web server and show the database content in a website. I want something that database in the web server updates itself from local server and show it to the website.


From your other question I see that you use tuptime.

To keep the DB synchronized you would need to copy it to your webserver every time it is locally updated. This assumes that your local computer is the only process that updates the DB and no other computer synchronizes with the webserver. You can store the DB under a different name on the webserver for each local computer if you need that.

The DB gets updated during startup and shutdown and regularly by a cronjob or a systemd timer. You need to amend all these jobs so that the file is copied to the webserver after every update.

For the shutdown event this might be a bit tricky because the network might already be down when the tuptime update process is triggered so you cannot copy the file to the server any more.

Once the file is copied to the webserver you can (and need to) write a web application that reads the content of the DB, prefereably with parameters set by the web user, and then display the results in a table or something.

The file can be copied with e.g. scp, i.e.:

scp /var/lib/tuptime/tuptime.db user@webserver:/var/lib/tuptime/tuptime-$HOSTNAME.db  

To make this run unattended you need to append your local public ssh key (usually ~/.ssh/id_rsa.pub) to the ~user/.ssh/authorized_keys file on the webserver.

Given the above points you can see that it is not as simple as issuing one single command.


You should be able to use scp /path/to/local/file user@remoteserver.url:/path/to/destination

More information on the scp command can be found here (https://help.ubuntu.com/community/SSH/TransferFiles)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »


Write comments
11 May 2018 at 10:44 delete

Maybe you can create a scheduled cron task to export the content of the database to a csv file with "tuptime --csv > /tmp/tuptime.csv" and scp that content to the web path of the remote server, there you can pase it with your web application to get a nice formatted view.