Hey guys, I just wanted to share this bash script I wrote to help with manual upgrade/migration. You may have to modify it to fit your needs, but it works well and has made it much easier to manually update my instances.
for i in $TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/*; do name=$(basename "$i") if [[ ! -e "$TARGET_WEBROOT/apps/$name" ]]; then cp -aR $TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/$name $TARGET_WEBROOT/apps/ echo "Apps restored"
Can you tell me what happens here?
I mean, I know you look at the apps in the backup folder, and if they are not in the new installation then you copy them there.
But at the top you have "for i". You never defined "i". "i" has no value. So when does your loop end?
Also what happens if your loop meets the match at first search? like the firewall app for example. Let's say it's in the original folder and in the new folder.
I think you missed some of the script as it does end. Additionally, it will not copy over any apps that exist in the destination and source. (As to avoid versioning issues with core apps)
for i in $TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/*; do name=$(basename "$i") if [[ ! -e "$TARGET_WEBROOT/apps/$name" ]]; then cp -aR $TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/$name $TARGET_WEBROOT/apps/ echo "Apps restored" fi done
Additionally i is defined as $TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/*
Meaning each folder contained within apps in the backup.
so i is the amount of folders in the backupfolder/apps.
The loop will execute the amount of times until there is no more folder left unchecked, right?
That's correct. The loop ends when they all get checked.
What happens here is pathname expansion (globbing):
$TARGET_WEBROOT-backup-$BACKUP_NUMBER/apps/* is substituted with all existiing pathnames in directory
For every pathname the loop gets executed and variable $i is set to the pathname.
Haha thank you for a clearer, better explanation!
Looks nice. Just one doubt, i guess this script requires that the data dir is placed outside of the webroot or am i wrong?
Yes, VERY good point! I'll add an option to restore data as well for those who do not keep their data outside of the webroot. Thank you very much for bringing that up!
It's been so long since I've had that setup, and this is a bit embarrassing to ask, but what is the name of the default data folder?
Ok, really good to know. While reading the code i thought there is some step missing, i think it some one has not moved the data dir out of the webroot this might break the installation.
The datadir itself is placed somewhere in /var/www/owncloud/data
Ok, this should do the trick: https://github.com/tabp0le/ownNextUpgrade/commit/4be7573d500babdc08743cab8baa8dc4a274788f
This solution should autodetect the presence and name of the data folder, provided it uses the word "data" somewhere in it.