Cloud syncing to central database from local servers laravel 4.2 - php

For my project, there are webapps installed on local servers. Whenever there is internet connection available, a press of a sync button on local server app should sync the database and the user uploaded files with central server. The central server should know from where the data is coming. I am building the local server apps using laravel 4.2. Is there a simple way I can achieve this?

I solved it using an extra column synced in all the tables on both local and cloud server and wrote code to send data through JSON APIs. Then, I updated the synced column with timestamp on both ends. And then on every sync button press, I compared updated and synced column and sent the data to the server accordingly.
I don't know if this is the perfect solution but worked for me.

Related

Working locally on an existing remote Laravel project linked with a database

I have recently joined a project that uses AWS EC2 to deploy a frontend in NodeJS and a backend in Laravel linked to a phpMyAdmin database. My question is simple but I have not found the way to do it despite litteral hours of research.
How can I launch the backend locally and use the corresponding database?
I should add that the database seems to be automatically generated by the Laravel backend and it contains a folder of "mutations".
I am relatively new to php, VMs and Linux overall.
Thank you for your help
This project is probably using mysql or mariadb as database engine.
You must install the engine and export all of data from server and import it in your local database.
If database is on server and you want to connect to that database, it depends on security mechanisms. You must expose the db engine's port in the server and changing your laravel config to use that host for database connection. But I don't recommend that!
If you just want to run backend for personal tests, just setup backend and database engine and run migrations. I can't help you with this step cause I don't know how are deploy operations in your team. If you provide more information, we can help better.

How to sync two Mysql database tables

I have my web based Qoute/Invoice system running at our local server (based on codeigniter). And our website hosted externally (one.com, based on Laravel). lets say i want table products and product families from database local be synced to the remote database in the representitive tables offcourse. Both mysql databases. Also the local database is the "master" so most changes will be made in the local database but i would like the remote database to sync so we can display our producs on the website. the only thing we could change in the remote database is if we display the product or not.
So the question is how i could get those two databases to sync. How could I do a script to do this?
From what i understand is you want two database from different servers to be synchronized. You can do that by setting up master-master replication.
Here's a good step by step documentation for you.
SymmetricDS can replicate between MySQL databases locally or remotely over HTTP or HTTPS. There is an open source version that might be sufficient for your needs.
SymmetricDS community
There is also a professional version if you want to add support.
SymmetricDS pro

CodeIgniter: How to synchronize local and remote databases

I have a Hotel monitoring web application developed in CodeIgniter.
It monitors each room of a hotel for activities and Sends live data about rooms occupancy, status of electrical switches etc.
It hosted in cpanel web server. I have the same copy of it in my local computer.
I want to synchronize the 2 databases (ie. in localhost and in remote server).
Every change in any database should be automaticaly updated to other database.
First I tried to access my remote database from localhost by putting host name as my cpanel Shared IP Address as follos
$db['default']['hostname'] = 'xx.xx.xx.xx';
where xx.xx.xx.xx is the shared IP of cpanel. but no use.
how should I proceed?
Thanks in advance
Option 1: The Codeigniter Way
You can set up a remote access MySQL server:
Tutorial for cpanel here: https://www.liquidweb.com/kb/enable-remote-mysql-
connections-in-cpanel/
Then just set up a new connection in your database.php changing the to $db['remote']['hostname'] = 'xxx.xxx.xxx.xxx';
Do note that you'll have to make a method to pull in this new data and replace it in your local database, so a script that can be run via cronjob.
Option 2: The Master/Slave Way
You can set up a Master database, being the hotel, and a slave being your local database. I don't know of a method to do this straight cpanel, but you can do it in phpmyadmin, there's a video on how to do it here: https://www.youtube.com/watch?v=nfsmnx24gxU
This method would be the most comprehensive/automatic way to do it. It will overwrite any changes in your database though.
Note that any outside access to a database is potentially insecure. Be aware of this when choosing.

Windows Embedded Handhel 6.5 app development synchronize windows PC

What is the best alternative to synchronize an app on Windows Mobile 6.5 with SQL Server Compaq with an php aplication on a PC server.
The phone does not always have internet access beacouse coverage issues, also can be connected to a PC via USB.
The data are in a table in SQL Server Compaq on the phone, the data are text and a number, associated through an identifier. This is updated from time to time where there is no internet connection. Then this data update a database in SQL Server 2008 on a server that has internet access.
There is also the possibility to update the phone's data table from the server to add more data to be updated in the field.
I hope you understand me because English is not my native language.
I was thinking of using exchange to send emails with updated data or use a service like dropbox to keep an updated file and that file is processed.
Which approach is better?
I hope you can guide me.
thank you very much.
If you are running a SQLClient on the CE device that connects to a SQL server, the best solution is to use the SQL synchronization options. This is also called RDA, see for example: http://etutorials.org/Programming/building+solutions+with+the+microsoft+net+compact+framework/Part+II+Essential+Architectural+Concepts/Chapter+7.+Data+Synchronization/RDA/
If the databases on the device and on the server are not connected, the automatic ID generation on the device and the server create different unique IDs. These will result in a conflict, when you update the data from multiple sources. If you do not need to handle conflicts with multiple sources updating the same database, you may simple send the updates between the server and the client and vice versa on regular intervals using http GET/POST or simple socket server/client.
Usually sometimes disconnected devices use http or another network protocol to pull and push updates. Files are rarely used for push/pull updates.
As you used the php TAG for this question too, using http with a php server with a database in the background, you can use php to extract data sent via GET/POST and also provide data back to the device using xml (or another format).

How to update remote server application from local server application

I have a PHP/MySQL application running with WAMP on a local server. This application contains sensitive and confidential data that can only be accessed from devices on the network in the office.
However, this application generates reports that clients should be able to access from the web from an entirely separate application running on a LAMP stack.
Currently, I have the reports transferring via SFTP from the local server to the web based server.
My question is, how can I update the remote database from the local application securely, and so that the MySQL db can only be modified by the localhost of the remote application and the server running the local application?
I'm thinking about creating some kind of API that only accepts data from the IP of the local app, but I do not know the best practices for this, nor do I know how to start going about it.
MySQL provides a USER > FROM HOST > PER DATABASE > PER TABLE > PER COLUMN grant system.
Meaning that you can specify which user can connect from which host to which database,... Make usage of the FROM HOST feature.

Categories