Reputation: 167
I run my php application on elastic beanstalk. Whenever, I push updates from my local repository, using git aws.push
, a directory called picture
along with it's all content is deleted from server. The local version of this directory is added to .gitignore
, because I don't want to push it to the server. The directory on server should remain intact, as it contains uploaded images. How should I stop the directory from being deleted every time I push?
Upvotes: 1
Views: 2144
Reputation: 537
Just to add, but from what I've seen this only applies to your app directory at var/app/current, which is indeed cleared out after you push your changes.
Files anywhere else aren't touched, we use config files to download maxmind geo dbs locally and they survive until the instance terminates.
Upvotes: 0
Reputation: 137268
Like most Platform as a Service providers, Elastic Beanstalk does not provide a persistent filesystem:
Persistent Storage
AWS Elastic Beanstalk applications run on Amazon EC2 instances that have no persistent local storage. When the Amazon EC2 instances terminate, the local file system is not saved, and new Amazon EC2 instances start with a default file system. You should design your application to store data in a persistent data source. Amazon Web Services offers a number of persistent storage options that you can leverage for your application, including
- Amazon Simple Storage Service (Amazon S3). For more information about Amazon S3, go to the documentation.
- Amazon Elastic Block Store (Amazon EBS). For more information, go to the documentation and see also the article Feature Guide: Elastic Block Store.
- Amazon DynamoDB. For more information, go to the documentation. For an example using Amazon DynamoDB with AWS Elastic Beanstalk, see Example: DynamoDB, CloudWatch, and SNS.
- Amazon Relational Database Service (Amazon RDS). For more information, go to the documentation and see also Amazon RDS for C# Developers.
This means that you cannot store files dynamically and expect them to survive a new deployment.
The recommended solution is to use a cloud file storage provider like S3.
Upvotes: 4