backup-folder-with-correct-owner-and-group

Step 3: Create a Backup of the Magento Folder (Optional)

1. Use the Change Directory command, followed by two dot to move one level up in the directory
tree. Then, list the directory so you can see the magento folder.
cd ..
ls -l
2. Enter the following command to create a new folder, called backup.
mkdir backup
ls -l
a. If you get a “Permission denied” message, add sudo to the beginning of the Make
Directory command. Then, list the directory to see the folder that you created.
sudo mkdir backup
sudo ls -l
b. The backup folder must have the same owner and group as the magento folder. If not,
enter the following command to change the ownership of the backup folder and its
contents.
In this command, the backup folder is assigned to the apache user and root group, and
followed by a single dot. (Don’t forget to use sudo if you need super administrator access.)
chown -hR apache:root backup .
ls -l
c. Enter the “who am I” command to see if you are logged in as the correct owner.
whoami
d. If you are not logged in as the web server or apache user, enter the following command.
When prompted, enter the password for the web server or apache user account.
su – apache
Notice that the prompt has changed. You are now in the bash folder of the apache user.
While you’re logged in as the apache user, you won’t need to use sudo for super
administrator access.
3. Use the Change Directory command to return to the location of your magento and backup
folders. List the directory to see where you are. Then, check to see who you are.
cd /var/www/html/stores/ce
ls -l
whoami

4. Copy the contents of the magento folder to the backup folder.
cp -r magento/* backup
5. Wait for the process to complete and for the system prompt to return. Then, take a look at the
contents of the backup folder to make sure the files were copied.
cd backup
ls -l
cd ..
6. Because you’ll be working with the backup folder for awhile, it’s a good idea to restore the
original permissions to your magento folder before continuing.
Enter the following commands to restore the recommended permissions to the magento folder.
Then, list the directory to verify that the permissions are restored.
To save time, copy each command from the example, and press the mouse button to paste it into
the command line.

Lock Down Permissions

ls -l
cd magento
find . -type d -exec chmod 500 {} \;
find . -type f -exec chmod 400 {} \;
find var/ -type f -exec chmod 600 {} \;
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \;
find media/ -type d -exec chmod 700 {} \;
ls -l

Leave a Comment

Your email address will not be published. Required fields are marked *