I was migrating our Discourse instance from a server to another, and came across an interesting issue…
We use S3 to store uploads from the forum. We have enabled them several years ago, hence it’s not something we introduced in this migration.
After fixing a couple of other issues, I was able to get the backup to be imported. But, it failed on a S3-related step with the following:
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
72038 posts were flagged for a rebake
EXCEPTION: 257 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
After digging a bit, I was able to trace down the issue to this line:
Then, I went to the rails console, and I was able to replicate the queries with the following:
Apparently, that check is retrieving any post containing /uploads/default/original in the cooked field, despite it might not be a legitimate asset. In this case, /uploads/default/original was used as “plain text”, hence it was not missed during the migration job.
הצלחתי לשחזר אותו במלואו פשוט על ידי החלפת הטקסט בפוסטים האלה כך שלא יתאים למסנן. זה לא היה בעיה עבורי, אבל רק מעלה את זה למקרה שמישהו יתמודד עם אותה בעיה, מכיוון שאולי כדאי לתקן את זה ב-Discourse.
אני די בטוח שגם אני נתקלתי בזה כשניסיתי לשחזר גיבוי ויצרתי את הגיבוי כשהאפשרות “כלול העלאות” כבויה. האם יש משהו נוסף שאני מפספס בשחזור של מסד הנתונים בלבד?
אני חדש בדיסקרוס אז אנסה להבין איך לעקוף את זה, אבל זה נראה כמו עדיפות גבוהה יותר אם הגיבוי/שחזור לא עובד כראוי עבור משתמשים שיש להם דלי S3 כאחסון העלאות.
עדכון לגבי המצ
ב הספציפי שלי… עדיין היו לי קבצים ב-/var/discourse/shared/standalone/uploads למרות שהחלפתי ל-S3 לאחסון. לאחר שמחקתי את ספריית ‘default’ בספריית ההעלאות הזו ויצרתי מחדש גיבוי, הוא יצר בהצלחה גיבוי של מסד נתונים בלבד (…sql.gz).
מסיבה כלשהי (במקרה שלי), אם יש קבצים בספרייה זו, ההגדרה לא לכלול קבצים שהועלו בגיבוי מתעלמת ממנה והקבצים נוצרים בכל מקרה.
ספרו לי אם נדרש מידע נוסף או הבהרות למצבי. נראה שזה אולי שונה במקצת מהמצב של פותח השרשור.
בכל מקרה, הצלחתי לעקוף את הבעיה וכעת אני יכול לשחזר בהצלחה.