0

Im using magento and i want write script to automatically backup so i want store the outside the magento 2 root directory is it possible and how can i do it.

1 Answer 1

2

You can do outside Magento folder.

First create a plugin for Magento\Backup\Helper\Data of function getBackupsDir(). Then on afterGetBackupsDir changes the dir of backup.

Define plugin in di.xml

Define plugin at a app/code/{Vendor}/{Modulename}/di.xml

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Backup\Helper\Data"> <plugin name="change_backup_dir" type="{VendorName}\{Modulename}\Plugin\DataBackupPlugin" sortOrder="1" /> </type> </config> 

Plugin Class:

<?php namespace {VendorName}\{Modulename}\Plugin; class DataBackupPlugin { public function afterGetBackupsDir( \Magento\Backup\Helper $subject, array $result ) { /* Should Use Absolulated path */ /* Here i have set my back directory is /var/www/ */ return '/var/www/'; } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.