Does Heroku deploy automatically delete server files?

I am new to HEROKU APPS .

I have a problem in my heroku application. I am using php script to save data on server.

Example:

 <?PHP $file = "example.txt"; $data = "Something..."; file_put_contents($file,$data); ?> 

This PHP script runs successfully and saves data perfectly.

But when deploying my APP to HEROKU to update -> in this precession example.txt file is automatically deleted.

+7
source share
3 answers

Heroku File Systems

Heroku's behavior is slightly dependent on the stack you use. With Bamboo, most of the read-only file system. With Cedar it is ephemeral .

In any case, file systems are not shared between dynos and should not be used for storage. To reliably store data on the server side, you will need to use a database (perhaps save your downloads as drops) or as external resources on another host or service.

+10
source

Heroku does not provide hard disk space for persistent files between git push, you will have to use something like Amazon S3 to store files. That's why Heroku calls its file system the Ephemeral file system. It was even read-only in earlier versions of the stack.

Heroku has a tutorial: Using AWS S3 to store static assets and upload files

+2
source

Please see the documents :

Ephemeral file system

Each dyno gets its own ephemeral file system with a fresh copy of the most recently deployed code. During the dynos life cycle, its running processes can use the file system as temporary notebook memory, but no files that are written are visible to processes in any other dyno, and any recorded files will be discarded when dyno stops or restarts.

Thus, you cannot save a lot with your Heroku dinar. Especially after you click on your new version, dyno will reboot, and the file system will reset.

You need to store the files in a remote place, and then if they need to survive dyno reset.

0
source

All Articles