Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure blob sync #191

Merged
merged 3 commits into from Jul 14, 2019

Conversation

@jbouzekri
Copy link
Contributor

commented Jul 14, 2019

Add Azure Blob Sync

@sebastianfeldmann : I am not sure if I have modified everything correctly for the ant task to build the phar package.


Test

List containers in storage account : none

$ az storage container list --connection-string 'xxxxxxxx' --subscription xxxxxxx
[]

List local backup generated : none

$ ls backup/

Configuration : tar local folder htdocs and upload it to mycontainer on Azure at path backup/ with remote cleanup by quantity (keep 2)

$ cat test.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/5.2/phpbu.xsd">
    <backups>
        <backup name="test">
            <source type="tar">
                <option name="path" value="htdocs" />
            </source>

            <target dirname="backup"
                    filename="htdocs-%Y%m%d-%H%i.tar"
                    compress="bzip2"/>

            <sync type="azureblob">
                <option name="connection_string" value="xxxxxxxx" />
                <option name="container_name" value="mycontainer" />
                <option name="path" value="backup" />
                <option name="cleanup.type" value="quantity" />
                <option name="cleanup.amount" value="2" />
            </sync>
            <cleanup type="quantity">
                <option name="amount" value="2"/>
            </cleanup>
        </backup>
    </backups>
</phpbu>

First run

$ php phpbu --configuration=test.xml
phpbu 6.0-dev by Sebastian Feldmann and contributors.

Time: 1 second, Memory: 6.00MB

OK (1 backup, 0 checks, 0 crypts, 1 sync, 1 cleanup)

One local backup generated

$ ls backup/
htdocs-20190707-1917.tar.bz2

One backup synced to Azure

$ az storage blob list  --container-name mycontainer --connection-string 'xxxxxxxx' --subscription xxxxxxx --query '[].{name:name}' -o json
[
  {
    "name": "backup/htdocs-20190707-1917.tar.bz2"
  }
]

Second run

$ php phpbu --configuration=test.xml
phpbu 6.0-dev by Sebastian Feldmann and contributors.

Time: 1 second, Memory: 6.00MB

OK (1 backup, 0 checks, 0 crypts, 1 sync, 1 cleanup)

Two local backups

$ ls backup/
htdocs-20190707-1917.tar.bz2  htdocs-20190707-1919.tar.bz2

Another one synced to Azure. Two available

$ az storage blob list  --container-name mycontainer --connection-string 'xxxxxxxx' --subscription xxxxxxx --query '[].{name:name}' -o json
[
  {
    "name": "backup/htdocs-20190707-1917.tar.bz2"
  },
  {
    "name": "backup/htdocs-20190707-1919.tar.bz2"
  }
]

Third run

$ php phpbu --configuration=test.xml
phpbu 6.0-dev by Sebastian Feldmann and contributors.

Time: 1 second, Memory: 6.00MB

OK (1 backup, 0 checks, 0 crypts, 1 sync, 1 cleanup)

Still 2 local backups. htdocs-20190707-1917.tar.bz2 removed.

$ ls backup/
htdocs-20190707-1919.tar.bz2  htdocs-20190707-1920.tar.bz2

Still 2 remote backups. backup/htdocs-20190707-1917.tar.bz2 removed.

$ az storage blob list  --container-name mycontainer --connection-string 'xxxxxxxx' --subscription xxxxxxx --query '[].{name:name}' -o json
[
  {
    "name": "backup/htdocs-20190707-1919.tar.bz2"
  },
  {
    "name": "backup/htdocs-20190707-1920.tar.bz2"
  }
]

@sebastianfeldmann sebastianfeldmann self-assigned this Jul 14, 2019

@sebastianfeldmann sebastianfeldmann self-requested a review Jul 14, 2019

@sebastianfeldmann
Copy link
Owner

left a comment

This look quite complete ;)

Thanks

@sebastianfeldmann sebastianfeldmann merged commit 281cc9b into sebastianfeldmann:master Jul 14, 2019

1 of 2 checks passed

Scrutinizer Errored
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sebastianfeldmann

This comment has been minimized.

Copy link
Owner

commented Jul 14, 2019

Thanks a lot mate

@jbouzekri jbouzekri deleted the jbouzekri:azure-blob-sync branch Jul 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.