HowTo: Customer Backups into OwnCloud

  • I provide for my customers 5GB Cloud Space.


    A customer asked me, if it is possible to place the backups in his cloudspace once a week.
    I said, i try to find a solution.


    Here is my HowTo if somebody need it:


    Install OwnCloud on a Webspaceaccount as described here http://owncloud.org/install/
    It is ok, to use sqlite as DB.
    Make sure, that this domain has disabled the backup function in i-MSCP (or only sql if you use sqlite).
    You can leave it to full only if the domain which is running owncloud is the first domain added on this server (i.e. vu2003).


    Login into your server via ssh
    create the folder "backups" in /var/www/virtual/CLOUDDOMAIN.DE/htdocs/CLOUDFOLDER/core/skeleton/


    Add all user in OwnCloud and login once in their account to create the folders. sorry, i didn´t found another solution for this ( YET ;) ) without a rewrite of the owncloud code.


    After that, you have to modifie the file /etc/imscp/imscp.conf
    Search for:

    Code
    1. USER_WEB_DIR = /var/www/virtual


    Add after this: (replace CLOUDDOMAIN.DE with your domain and CLOUDFOLDER with the folder of your OwnCloud installation)

    Code
    1. USER_CLOUD_DIR = /var/www/virtual/CLOUDDOMAIN.DE/htdocs/CLOUDFOLDER/data/


    create a copy of /var/www/imscp/engine/backup/imscp-backup-all

    Code
    1. cp /var/www/imscp/engine/backup/imscp-backup-all /var/www/imscp/engine/backup/imscp-backup-cloud


    modify the file /var/www/imscp/engine/backup/imscp-backup-cloud


    Search for:

    Code
    1. my $homeDir = "$main::imscpConfig{'USER_WEB_DIR'}/$rdata->{$_}->{'domain_name'}"; my $bkpDir = "$homeDir/backups";


    change it like this:

    Code
    1. my $homeDir = "$main::imscpConfig{'USER_WEB_DIR'}/$rdata->{$_}->{'domain_name'}"; my $cldDir = "$main::imscpConfig{'USER_CLOUD_DIR'}/$rdata->{$_}->{'domain_name'}"; my $bkpDir = "$cldDir/files/backups";


    The last is, to add a cronjob to start the script once a weel


    goto /etc/cron.d
    create a file with the name cloud and fill it with the following
    (change the vuXXXX with the vu of owncloud and the path to the data directory )

    Code
    1. ## cron.d/cloud -- schedules periodic start of imscp-backup-cloud to# create backups from user webfolder and databases into users owncloud space## Copyright © Peter Ziergoebel <[email protected]>## Run once a week on sunday* * * * 0 root /var/www/imscp/engine/backup/imscp-backup-cloud yes &>/var/log/imscp/imscp-backup-cloud.log && chown -R vuXXXX:vuXXXX /var/www/virtual/CLOUDDOMAIN.DE/htdocs/CLOUDFOLDER/data/


    Restart cron

    Code
    1. /etc/init.d/cron restart


    IMPORTANT !!!
    After an update of i-MSCP the imscp.conf has to be edit again.


    That´s it.

  • Here is the Hook file.
    I am sorry if the code looks not so good. It´s my first perl script.


    You have to install OwnCloud and do all things which are described here.
    Then place the attached file into /etc/imscp/hooks.d (remove .txt first)


    Edit

    Code
    1. my $owncloud_data_dir = ' = /var/www/virtual/cloud-domain.de/htdocs/data/';


    Make the file readable only for root (chmod 0600)


    If the imscp.conf will be overwritten by imscp-setup, the Hook file writes the USER_CLOUD_DIR variable into imsccp.conf

  • Before somebody asks what happens:
    Issue: the files for the cron and imscp-backup-cloud will be deleted on upgrade to latest release


    Solution: new hook file will be released next days.

  • New Hook file.


    Changes:
    - Create a copy of imscp-backup-cloud and "/etc/cron.d/cloud" to /tmp
    - move the files to the right locations after setup is done.


    I´ve tested it serval times and it works for me.

  • @FISA4


    I've not time ATM but I'll comment your hook ASAP. I see many thing which can be improved.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206