meine Backupstrategie sollte ich aber trotzdem verbessern. 🤭
Erst einmal Danke für die Rückmeldung.
Für das Backup hätte ich ein PowerShellScript für Dich, wenn Du magst.
Außerdem gibt es ein JavaScript, mit dem Du ebenfalls Dein Profil sichern kannst!
JavaScript
// BackupProfile.uc.js
// Schaltfläche zum Sichern des Firefox-Profils
/* ----------------------------------------------------------------------------------- */
/* Zu beachten ist, dass die Grafiken sich im richtigen Ordner befinden müssen */
/* %appdata%\Mozilla\Firefox\Profiles\"Profilname"\chrome\icons */
/* ----------------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------------- */
/* IMPORTANT! This script was edited and modified using AI. */
/* ----------------------------------------------------------------------------------- */
'use strict';
(function() {
if (location.href !== 'chrome://browser/content/browser.xhtml')
return;
const
// ■■ START UserConfiguration ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
id = 'backupProfile-button', // ID des Buttons
label = 'Profilsicherung', // Bezeichnung des Buttons
tooltiptext = 'Sichern der aktuellen Konfiguration',
icon = 'backup.svg', // Name des SVG-Icons
colour = '#faea00', // Farbe für das SVG-Icon
iconPath = '/chrome/icons/', // Pfad zum Icon-Ordner
basePath = 'E:\\Firefox-Sicherung\\', // Standard-Speicherpfad (leer lassen für Dialog)
iconSize = '32px', // ⭐ NEU: Icon-Größe
// Ausschlussliste (Dateien/Ordner, die nicht gesichert werden sollen)
excludes = 'bookmarkbackups *cache* crashes fftmp *healthreport* minidumps safebrowsing *webapps* saved-telemetry-pings *thumbnails* *session* *Telemetry* *hotfix* *.sqlite-shm *.sqlite-wal *.bak parent.lock blocklist.xml content-prefs.sqlite directoryLinks.json mimeTypes.rdf compatibility.ini parent.lock formhistory.sqlite',
// ■■ END UserConfiguration ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
curProfDir = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir));
// SVG-Unterstützung aktivieren (falls nicht bereits aktiv)
if (Services.prefs.getBoolPref('svg.context-properties.content.enabled') == false) {
Services.prefs.setBoolPref('svg.context-properties.content.enabled', true);
}
// ---- BUTTON ERSTELLEN ----
try {
CustomizableUI.createWidget({
id: id,
defaultArea: CustomizableUI.AREA_NAVBAR,
label: label,
tooltiptext: tooltiptext,
onCreated: (button) => {
button.style.MozContextProperties = 'fill, stroke, fill-opacity';
button.style.listStyleImage = 'url("' + curProfDir + iconPath + icon + '")';
button.style.minWidth = 'fit-content';
button.style.color = colour;
}
});
} catch(e) {}
// ---- ICON-GRÖßE ANPASSEN (CSS Injection) ----
let sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
#${id} .toolbarbutton-icon {
width: ${iconSize} !important;
height: ${iconSize} !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
// ---- FUNKTIONEN ----
function showAlert(aTitle, aString) {
const AlertNotification = Components.Constructor(
'@mozilla.org/alert-notification;1',
'nsIAlertNotification',
'initWithObject'
);
Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlert(
new AlertNotification({ title: aTitle, text: aString })
);
}
function performBackup() {
let path = basePath;
if (!path) {
const nsIFilePicker = Ci.nsIFilePicker;
const FP = Cc['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
FP.init(window, 'Sicherungspfad wählen', nsIFilePicker.modeGetFolder);
if (FP.show() !== nsIFilePicker.returnOK) {
return;
}
path = FP.file.path;
}
const excludesRegex = new RegExp(
excludes.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\s+/g, '|'),
'i'
);
const zw = Cc['@mozilla.org/zipwriter;1'].createInstance(Ci.nsIZipWriter);
const pr = {PR_RDONLY: 0x01, PR_WRONLY: 0x02, PR_RDWR: 0x04, PR_CREATE_FILE: 0x08, PR_APPEND: 0x10, PR_TRUNCATE: 0x20, PR_SYNC: 0x40, PR_EXCL: 0x80};
const fu = ChromeUtils.importESModule('resource://gre/modules/FileUtils.sys.mjs').FileUtils;
const dir = new FileUtils.File(PathUtils.join(PathUtils.profileDir, []));
const d = new Date();
const dateStr = d.getDate().toString().padStart(2, '0') + '.' +
(d.getMonth() + 1).toString().padStart(2, '0') + '.' +
d.getFullYear() + ' - ' +
d.getHours().toString().padStart(2, '0') + '\u2236' +
d.getMinutes().toString().padStart(2, '0');
const archiveName = 'Profil Andreas ' + AppConstants.MOZ_APP_VERSION_DISPLAY + ' - ' + dateStr + '.zip';
const xpi = fu.File(path + '\\' + archiveName);
zw.open(xpi, pr.PR_RDWR | pr.PR_CREATE_FILE | pr.PR_TRUNCATE);
const dirArr = [dir];
for (let i = 0; i < dirArr.length; i++) {
const dirEntries = dirArr[i].directoryEntries;
while (dirEntries.hasMoreElements()) {
const entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if (entry.path === xpi.path) continue;
if (entry.isDirectory()) {
dirArr.push(entry);
}
const relPath = entry.path.replace(dirArr[0].path, '');
if (relPath.match(excludesRegex)) continue;
const saveInZipAs = relPath.substr(1).replace(/\\/g, '/');
try {
zw.addEntryFile(saveInZipAs, Ci.nsIZipWriter.COMPRESSION_FASTEST, entry, false);
} catch (e) {}
}
}
zw.close();
showAlert('Profilsicherung', 'Die aktuelle Konfiguration wurde als:\n' + archiveName + '\ngesichert in:\n' + path);
}
// ---- KLICK-HANDLER ----
(function setupClickHandler() {
const button = document.getElementById(id);
if (button) {
button.addEventListener('click', event => {
if (event.button !== 0) return;
performBackup();
});
} else {
setTimeout(setupClickHandler, 100);
}
})();
})();
Alles anzeigen