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
Merged

Conversation

@jbouzekri
Copy link
Contributor

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

@sebastianfeldmann sebastianfeldmann left a comment

This look quite complete ;)

Thanks

Loading

@sebastianfeldmann sebastianfeldmann merged commit 281cc9b into sebastianfeldmann:master Jul 14, 2019
1 of 2 checks passed
Loading
@sebastianfeldmann
Copy link
Owner

@sebastianfeldmann sebastianfeldmann commented Jul 14, 2019

Thanks a lot mate

Loading

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

Successfully merging this pull request may close these issues.

None yet

2 participants