Uploaded files getting deleted while redeploying in Openshift server

572 views Asked by At

After pushing the whole application, The whole application is working fine. Then I upload some files to my uploads folder via my web interface.

If I push the code via git, All the files in uploads folder is deleting automaticaly. Is there a way to stop this in my openshift server ?

2

There are 2 answers

3
Tim On BEST ANSWER

Your application should be storing any persistent files in the $OPENSHIFT_DATA_DIR, which is usually ~/app-root/data. Your application is likely storing these "uploads" into the $OPENSHIFT_REPO_DIR, where your code lives. This directory is overwritten with your new code every time you git push.

You need to configure your application to store the uploads in $OPENSHIFT_DATA_DIR to store them persistently.

0
Ronnel On

on your root wordpress local create a dir for action hook

mkdir -p .openshift/action_hooks

then create deploy hook

vim .openshift/action_hooks/deploy

paste this

#!/bin/bas
echo "Creating symlink folder of uploads" 
if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
    mkdir ${OPENSHIFT_DATA_DIR}uploads
fi
ln -svf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}wp-content/uploads

NOTE: The .openshift/action_hooks/deploy hook is not executable, to make it executable:

On Windows: git update-index --chmod=+x .openshift/action_hooks/deploy

On Linux/OSX: chmod +x .openshift/action_hooks/deploy

add changes, commit and push.