Last active
May 24, 2022 14:50
-
-
Save jivanpal/e4e12d34e97c30ca8e6bb9ad236a7f7f to your computer and use it in GitHub Desktop.
s3backer scripts for Nextcloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p /mnt/nextcloud-bucket/{s3backer,filesystem} | |
s3backer \ | |
--listBlocks \ | |
\ | |
--blockSize=1M \ | |
--size=500G \ | |
\ | |
--blockCacheFile=/mnt/nextcloud-bucket/blockCacheFile \ | |
--blockCacheMaxDirty=64 \ | |
--blockCacheSize=256 \ | |
--blockCacheThreads=1 \ | |
--blockCacheWriteDelay=1000 \ | |
\ | |
--encrypt \ | |
--passwordFile=/etc/s3backer/passwordFile \ | |
\ | |
--accessFile=/etc/s3backer/accessFile \ | |
--baseURL=https://s3.eu-central-1.wasabisys.com/ \ | |
\ | |
nextcloud-bucket \ | |
/mnt/nextcloud-bucket/s3backer | |
if [ $? -ne 0 ]; then | |
>&2 echo "Failed to mount S3 bucket." | |
exit 1 | |
fi | |
if ! mkfs.ext4 /mnt/nextcloud-bucket/s3backer/file; then | |
>&2 echo "Failed to create EXT4 filesystem on s3backer file." | |
exit 1 | |
fi | |
if ! mount /mnt/nextcloud-bucket/{s3backer/file,filesystem}; then | |
>&2 echo "Failed to mount EXT4 filesystem." | |
exit 1 | |
fi | |
if ! rsync -ahP /var/www/cloud.example.com/data /mnt/nextcloud-bucket/filesystem/data; then | |
>&2 echo "Rsync didn't complete successfully." | |
exit 1 | |
fi | |
mv /var/www/cloud.example.com/{data,data-old} | |
mkdir /var/www/cloud.example.com/data | |
if ! mount --bind /mnt/nextcloud-bucket/filesystem/data /var/www/cloud.example.com/data; then | |
>&2 echo "Failed to bind-mount new data dir to old data dir's location." | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p /mnt/nextcloud-bucket/{s3backer,filesystem} | |
s3backer \ | |
--listBlocks \ | |
\ | |
--blockCacheFile=/mnt/nextcloud-bucket/blockCacheFile \ | |
--blockCacheMaxDirty=64 \ | |
--blockCacheSize=256 \ | |
--blockCacheThreads=1 \ | |
--blockCacheWriteDelay=1000 \ | |
\ | |
--encrypt \ | |
--passwordFile=/etc/s3backer/passwordFile \ | |
\ | |
--accessFile=/etc/s3backer/accessFile \ | |
--baseURL=https://s3.eu-central-1.wasabisys.com/ \ | |
\ | |
nextcloud-bucket \ | |
/mnt/nextcloud-bucket/s3backer | |
if [ $? -ne 0 ]; then | |
>&2 echo "Failed to mount S3 bucket." | |
exit 1 | |
fi | |
if ! mount /mnt/nextcloud-bucket/{s3backer/file,filesystem}; then | |
>&2 echo "Failed to mount EXT4 filesystem." | |
exit 1 | |
fi | |
mkdir -p /var/www/cloud.example.com/data | |
if ! mount --bind /mnt/nextcloud-bucket/filesystem/data /var/www/cloud.example.com/data; then | |
>&2 echo "Failed to bind-mount data dir to required location." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mentioned here: nextcloud/server#22077 (comment)