Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NCDATA=/mnt/"$POOLNAME"
SNAPDIR=/var/snap/spreedme
GPGDIR=/tmp/gpg
SHA256_DIR=/tmp/sha256
BACKUP=/mnt/NCBACKUP
BACKUP=/mnt/NCBACKUP/"$(date +%Y-%m-%d-%H%M%S)"
NC_APPS_PATH=$NCPATH/apps
VMLOGS=/var/log/nextcloud

Expand Down
33 changes: 10 additions & 23 deletions nextcloud_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ then
export NEEDRESTART_SUSPEND=1
fi

# Save the list of enabled apps before upgrade (to re-enable them after upgrade)
# Create the backup dir (/mnt/NCBACKUP/"$(date +%Y-%m-%d-%H%M%S)") and save
# the list of enabled apps before upgrade (to re-enable them after upgrade)
# https://github.com/nextcloud/vm/issues/2797
print_text_in_color "$ICyan" "Saving list of enabled apps before upgrade..."
if [ ! -d "$BACKUP" ]
Expand All @@ -368,6 +369,9 @@ then
fi
nextcloud_occ app:list --enabled | sed '\|Disabled|,$d' | awk '{print$2}' | tr -d ':' | sed '\|^$|d' > "$BACKUP/enabled_apps_before_upgrade.txt"

# Remove backups older than one year
find /mnt/NCBACKUP/ -maxdepth 1 -mindepth 1 -type d -name "$(date --date='1 year ago' +%Y)*" -exec rm -rf {} +

# Enter maintenance:mode
print_text_in_color "$IGreen" "Enabling maintenance:mode..."
sudo -u www-data php "$NCPATH"/occ maintenance:mode --on
Expand Down Expand Up @@ -1094,10 +1098,12 @@ fi
print_text_in_color "$ICyan" "Stopping Apache2..."
check_command systemctl stop apache2.service

# Create backup dir (/mnt/NCBACKUP/)
if [ ! -d "$BACKUP" ]
# Move backups to location according to $VAR into a separate subfolder
if [ -d /var/NCBACKUP/ ]
then
mkdir -p "$BACKUP"
mv /var/NCBACKUP "$(dirname "$BACKUP")/$(date -r /var/NCBACKUP +%Y-%m-%d-%H%M%S)"
mv /var/NCBACKUP-OLD/* "$(dirname "$BACKUP")"/
rm -rf /var/NCBACKUP-OLD
fi

# Backup PostgreSQL
Expand Down Expand Up @@ -1145,25 +1151,6 @@ then
nextcloud_occ config:system:delete app_install_overwrite
fi

# Move backups to location according to $VAR
if [ -d /var/NCBACKUP/ ]
then
mv /var/NCBACKUP "$BACKUP"
mv /var/NCBACKUP-OLD "$BACKUP"-OLD/
fi

# Check if backup exists and move to old
print_text_in_color "$ICyan" "Backing up data..."
if [ -d "$BACKUP" ]
then
install_if_not rsync
mkdir -p "$BACKUP"-OLD/"$(date +%Y-%m-%d-%H%M%S)"
rsync -Aaxz "$BACKUP"/* "$BACKUP"-OLD/"$(date +%Y-%m-%d-%H%M%S)"
rm -rf "$BACKUP"-OLD/"$(date --date='1 year ago' +%Y)"*
rm -rf "$BACKUP"
mkdir -p "$BACKUP"
fi

# Do a backup of the ZFS mount
if is_this_installed zfs-auto-snapshot
then
Expand Down