Script for migrating Nextcloud primary storage from local to S3 storage :floppy_disk: to :cloud:
Fork from mrAceT
Revision
main
-4ab29ef
It will transfer files from local based primary storage to a S3 primary storage.
Before you start, it is probably wise to set $DO_FILES_CLEAN (occ files:cleanup) and $DO_FILES_SCAN (occ files:scan --all) to '1' once, let the 'Nextcloud' do some checking.. then you'll start out as clean as possible
make sure that the Nextcloud cron job is disabled and make sure that you local data is sufficiently large
go to the nextcloud root folder and install composer
wget https://getcomposer.org/installer
mv installer composer-setup.php
mkdir bin
php composer-setup.php --install-dir /var/www/html/nextcloud/bin
chown -R apache:apache bin
rm -f composer-setup.php
chmod 755 bin/*
runuser -u apache -- ./bin/composer.phar require aws/aws-sdk-php
sudo -u apache php81 -d memory_limit=1024M tests3.php
sudo -u apache php81 -d memory_limit=1024M localtos3.php
DO NOT skip ahead and go live ($TEST=0) as the first step.. then your downtime will be very long!
With performing 'the move' at step 8 you will decrease the downtime (with maintenance mode:on) immensely! This because the script will first check if it already has uploaded the latest file, then it can skip to the next and does not need to (slowly) upload it to your S3 bucket! With a litte luck the final run (with $TEST=0) can be done within a minute!
NOTE step 8 will take a very long time when you have a lot of data to upload!
If everything worked you might want to delete the data in data folder. Also you probably want to delete this script (and the 'storage.config.php') after running it. If all went as it should the config data in 'storage.config.php' is included in the 'config/config.php'. Then the 'storage.config.php' can also be removed from your config folder (no sense in having a double config)
When you
Then the script 'localtos3.php' will:
look for entries in S3 and not in the database and vice versa and remove them. This can happen sometimes upon removing an account, preview files might not get removed.. stuff like that..
check for canceled uploads. Inspired upon otherguy/nextcloud-cleanup. I have not had this problem, so can not test.. => check only!
preview cleanup. Removes previews of files that no longer exist. There is some initial work for clearing previews.. that is a work in progress, use at your own risc!
The script will do the "sanity check" when migrating also (we want a good and clean migrition, won't we? ;)