2

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 ?

Sriraman
  • 7,658
  • 4
  • 40
  • 60

2 Answers2

4

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.

Tim
  • 116
  • 4
  • How to move my uploads folder to $OPENSHIFT_DATA_DIR ? – Sriraman Dec 10 '14 at 17:45
  • That depends on your application code. You will need to modify where `uploads` are stored so that the uploads will be placed in the data directory. Alternatively, you can set up a symlink to the data directory in your build action hook. See this forum post (assuming you are using wordpress): https://forums.openshift.com/how-to-find-wordpress-uploads-folder – Tim Dec 10 '14 at 18:09
  • I agree with @Timbabwe, symlinks are the way to go, you can check out the WordPress quickstart for an idea of how the symlinks would work and where to create them: https://github.com/openshift/wordpress-example/blob/master/.openshift/action_hooks/deploy –  Dec 10 '14 at 20:51
1

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.

Ronnel
  • 11
  • 1