I am presently developing a Dapp and I am now trying to deploy it on cloud. So what I do is create an EC2 instance and drop all my code there. Then I install ganache-cli there and before on my local machine I used ganache GUI and here in GUI there is an option to create a workspace so that I don't lose my data on blockchain if my system restarts at any point in time but in the case of ganache-cli everytime it starts it creates new accounts and emulates a whole new network. So how do I proceed with this?
Ganache is a development and testing framework - fast and easy to set up and fast transaction blocks. Generally, it is preferable to start with an empty blockchain and rehearse the migration and initialization processes every time, for more most dev/test cases.
Ganache is not useful for production because there is no consensus. It's just your server going through the motions of pretending it's Ethereum. For this reason, it cannot connect to the real blockchain and never will.
Two nuanced cases spring to mind.
- Ganache can persist the state for next time.
- Ganache can initialize from a live blockchain and "fork." This is especially useful for production dApps with upgradable patterns. A developer can initialize with the live state (all user data, etc.), then fork with Ganache, rehearse an upgrade and run regression tests on the proposed upgrade.
Admittedly, I don't use the persisted state option very often for the reasons outlined above, but I think what you are looking for is:
--db: Specify a path to a directory to save the chain database. If a database already exists, ganache-cli will initialize that chain instead of creating a new one.
Hope it helps.
Plus to above answer, from what i tried to create workspace kind thing, you should also save the mnemonic words and then give them as a parameter for -m option not only giving the db path...
From my practice, if you just give db path only, you will get the different accounts each time...