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

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
Copy link
Owner

@sebastianfeldmann sebastianfeldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look quite complete ;)

Thanks

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

Thanks a lot mate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants