Skip to content

Commit 7f327d7

Browse files
committed
Adding the logic to move the contents of /export/home if its not empty, for a better user experience.
1 parent becf86f commit 7f327d7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

files/common/var/lib/delphix-platform/export-home

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ if mountpoint -q /export/home; then
3030
fi
3131

3232
# /export/home is not mounted, check if /home is mounted
33-
# Check if /home is mounted
3433
if mountpoint -q /home; then
3534
echo "/home is mounted. Proceeding with /export/home cleanup."
3635
# If /export/home exists
@@ -40,8 +39,16 @@ if mountpoint -q /home; then
4039
if [ $? -eq 0 ]; then
4140
echo "/export/home directory removed successfully."
4241
else
43-
echo "/export/home is not empty. Please clean it manually before running this script."
44-
exit 1
42+
# If rmdir fails, it means /export/home is not empty
43+
# Move contents to a backup location for a seamless user experience.
44+
echo "/export/home is not empty. Moving contents to /export/home.backup before cleanup..."
45+
backup_dir="/export/home.backup.$(date +%Y%m%d_%H%M%S)"
46+
mv /export/home "$backup_dir"
47+
if [ $? -ne 0 ]; then
48+
echo "Failed to move /export/home contents to backup. Manual intervention required."
49+
exit 1
50+
fi
51+
echo "Contents of /export/home moved successfully to: $backup_dir"
4552
fi
4653
fi
4754
else

0 commit comments

Comments
 (0)