Fix mount options in /etc/fstab when restoring a BTRFS snapshot to a non-BTRFS partition

This commit is contained in:
Tony George 2014-09-18 21:11:01 +05:30
parent 2adeb261e4
commit 46919f43d7
3 changed files with 71 additions and 36 deletions

View File

@ -147,7 +147,7 @@ public class Main : GLib.Object{
}
exit(0);
*/
App = new Main(args);
bool success = App.start_application(args);
App.exit_app();
@ -1825,6 +1825,22 @@ public class Main : GLib.Object{
//update fstab entry
fstab_entry.device = "UUID=%s".printf(mount_entry.device.uuid);
fstab_entry.type = mount_entry.device.type;
//fix mount options for / and /home
if (restore_target.type != "btrfs"){
if ((fstab_entry.mount_point == "/") && fstab_entry.options.contains("subvol=@")){
fstab_entry.options = fstab_entry.options.replace("subvol=@","").strip();
if (fstab_entry.options.has_suffix(",")){
fstab_entry.options = fstab_entry.options[0:fstab_entry.options.length - 1];
}
}
else if ((fstab_entry.mount_point == "/home") && fstab_entry.options.contains("subvol=@home")){
fstab_entry.options = fstab_entry.options.replace("subvol=@home","").strip();
if (fstab_entry.options.has_suffix(",")){
fstab_entry.options = fstab_entry.options[0:fstab_entry.options.length - 1];
}
}
}
}
}
@ -1868,7 +1884,7 @@ public class Main : GLib.Object{
//remove fstab entry for /home
fstab_list.remove(fstab_home_entry);
}
//write the updated file --------------
string text = "# <file system> <mount point> <type> <options> <dump> <pass>\n\n";
@ -1880,7 +1896,7 @@ public class Main : GLib.Object{
log_msg(_("Updated /etc/fstab on target device"));
//create folders for mount points in /etc/fstab (to prevent mount errors during boot) ---------
//create folders for mount points in /etc/fstab to prevent mount errors during boot ---------
foreach(FsTabEntry fstab_entry in fstab_list){
string mount_path = target_path + fstab_entry.mount_point[1:fstab_entry.mount_point.length];
@ -2220,10 +2236,12 @@ public class Main : GLib.Object{
foreach(PartitionInfo pi in partition_list){
if (pi.mount_points.contains("/")){
root_device = pi;
log_msg(_("/ is mapped to device: %s, UUID=%s").printf(pi.device,pi.uuid));
}
if (pi.mount_points.contains("/home")){
home_device = pi;
log_msg(_("/home is mapped to device: %s, UUID=%s").printf(pi.device,pi.uuid));
}
}
}
@ -2270,9 +2288,11 @@ public class Main : GLib.Object{
mount_point_backup = mount_point_app + "/backup";
check_and_create_dir_with_parents(mount_point_backup);
if (mount(backup_device.uuid, mount_point_backup, "")){
log_msg(_("Backup path changed to '%s/timeshift'").printf((mount_point_backup == "/") ? "" : mount_point_backup));
return true;
}
else{
mount_point_backup = "";
return false;
}
}
@ -2289,7 +2309,7 @@ public class Main : GLib.Object{
//automount
mount_point_backup = automount(backup_device.uuid,"", mount_point_app);
if (mount_point_backup.length > 0){
log_msg("Backup path changed to '%s/timeshift'".printf((mount_point_backup == "/") ? "" : mount_point_backup));
log_msg(_("Backup path changed to '%s/timeshift'").printf((mount_point_backup == "/") ? "" : mount_point_backup));
}
else{
App.update_partition_list();

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: timeshift 1.2\n"
"Report-Msgid-Bugs-To: teejee2008@gmail.com\n"
"POT-Creation-Date: 2014-09-17 23:38+0530\n"
"POT-Creation-Date: 2014-09-18 21:09+0530\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -21,6 +21,16 @@ msgstr ""
msgid "** Advanced Users **"
msgstr ""
#: Main.vala:2239
#, c-format
msgid "/ is mapped to device: %s, UUID=%s"
msgstr ""
#: Main.vala:2244
#, c-format
msgid "/home is mapped to device: %s, UUID=%s"
msgstr ""
#: MainWindow.vala:1237
msgid "A System Restore Utility for Linux"
msgstr ""
@ -61,11 +71,11 @@ msgstr ""
msgid "Any exclude patterns in the current exclude list will also be excluded."
msgstr ""
#: Main.vala:2120
#: Main.vala:2136
msgid "App config loaded"
msgstr ""
#: Main.vala:2056
#: Main.vala:2072
msgid "App config saved"
msgstr ""
@ -77,7 +87,7 @@ msgstr ""
msgid "Application Info"
msgstr ""
#: Main.vala:2407
#: Main.vala:2427
msgid "Application will exit"
msgstr ""
@ -123,7 +133,7 @@ msgstr ""
msgid "Backup device does not have enough space"
msgstr ""
#: Main.vala:2590 MainWindow.vala:1378 MainWindow.vala:1386
#: Main.vala:2610 MainWindow.vala:1378 MainWindow.vala:1386
msgid "Backup device does not have enough space!"
msgstr ""
@ -135,10 +145,15 @@ msgstr ""
msgid "Backup device is not mounted!"
msgstr ""
#: Main.vala:2577 Main.vala:2584
#: Main.vala:2597 Main.vala:2604
msgid "Backup device not available"
msgstr ""
#: Main.vala:2291 Main.vala:2312
#, c-format
msgid "Backup path changed to '%s/timeshift'"
msgstr ""
#: MainWindow.vala:1066
msgid "Before restoring"
msgstr ""
@ -229,15 +244,15 @@ msgstr ""
msgid "Credits"
msgstr ""
#: Main.vala:2406
#: Main.vala:2426
msgid "Critical Error"
msgstr ""
#: Main.vala:2527
#: Main.vala:2547
msgid "Cron job added"
msgstr ""
#: Main.vala:2540
#: Main.vala:2560
msgid "Cron job removed"
msgstr ""
@ -269,7 +284,7 @@ msgstr ""
msgid "Delete Snapshot"
msgstr ""
#: Main.vala:2004
#: Main.vala:2020
msgid "Deleted"
msgstr ""
@ -429,7 +444,7 @@ msgstr ""
msgid "Excluded Directories"
msgstr ""
#: Main.vala:2531
#: Main.vala:2551
msgid "Failed to add cron job"
msgstr ""
@ -449,7 +464,7 @@ msgstr ""
msgid "Failed to delete symlinks"
msgstr ""
#: Main.vala:2710 Main.vala:2716
#: Main.vala:2730 Main.vala:2736
msgid "Failed to estimate system size"
msgstr ""
@ -461,7 +476,7 @@ msgstr ""
msgid "Failed to get partition list"
msgstr ""
#: Main.vala:2196
#: Main.vala:2212
msgid "Failed to get partition list."
msgstr ""
@ -469,7 +484,7 @@ msgstr ""
msgid "Failed to hard-link last snapshot"
msgstr ""
#: Main.vala:2344 Main.vala:2352
#: Main.vala:2364 Main.vala:2372
msgid "Failed to mount BTRFS subvolume"
msgstr ""
@ -477,7 +492,7 @@ msgstr ""
msgid "Failed to mount device"
msgstr ""
#: Main.vala:2544
#: Main.vala:2564
msgid "Failed to remove cron job"
msgstr ""
@ -497,7 +512,7 @@ msgstr ""
msgid "Failed to unmount"
msgstr ""
#: Main.vala:2407
#: Main.vala:2427
msgid "Failed to unmount device!"
msgstr ""
@ -526,7 +541,7 @@ msgstr ""
msgid "First Snapshot"
msgstr ""
#: Main.vala:2599 MainWindow.vala:1387
#: Main.vala:2619 MainWindow.vala:1387
msgid "First snapshot needs"
msgstr ""
@ -770,7 +785,7 @@ msgstr ""
msgid "Nothing to do!"
msgstr ""
#: Main.vala:2768
#: Main.vala:2788
msgid "Older log files removed"
msgstr ""
@ -778,7 +793,7 @@ msgstr ""
msgid "On-demand snapshot failed!"
msgstr ""
#: Main.vala:320 Main.vala:2321 RestoreWindow.vala:1298
#: Main.vala:320 Main.vala:2341 RestoreWindow.vala:1298
msgid ""
"Only ubuntu-type layouts with @ and @home subvolumes are currently supported."
msgstr ""
@ -829,7 +844,7 @@ msgstr ""
msgid "Please select a snapshot to view the log!"
msgstr ""
#: Main.vala:2574 MainWindow.vala:1367
#: Main.vala:2594 MainWindow.vala:1367
msgid "Please select the backup device"
msgstr ""
@ -889,7 +904,7 @@ msgstr ""
msgid "Remove selected items"
msgstr ""
#: Main.vala:2380 Main.vala:2627
#: Main.vala:2400 Main.vala:2647
#, c-format
msgid "Removed mount directory: '%s'"
msgstr ""
@ -1059,7 +1074,7 @@ msgstr ""
msgid "Snapshot"
msgstr ""
#: Main.vala:1953
#: Main.vala:1969
msgid "Snapshot deleted"
msgstr ""
@ -1160,7 +1175,7 @@ msgstr ""
msgid "Target"
msgstr ""
#: Main.vala:2810
#: Main.vala:2830
msgid "Terminating rsync process"
msgstr ""
@ -1172,7 +1187,7 @@ msgstr ""
msgid "The system partition has an unsupported subvolume layout."
msgstr ""
#: Main.vala:2320 RestoreWindow.vala:1297
#: Main.vala:2340 RestoreWindow.vala:1297
msgid "The target partition has an unsupported subvolume layout."
msgstr ""
@ -1215,7 +1230,7 @@ msgstr ""
msgid "UUID"
msgstr ""
#: Main.vala:1947 Main.vala:2000
#: Main.vala:1963 Main.vala:2016
msgid "Unable to delete"
msgstr ""
@ -1227,11 +1242,11 @@ msgstr ""
msgid "Unmounting from"
msgstr ""
#: Main.vala:2324 RestoreWindow.vala:1296
#: Main.vala:2344 RestoreWindow.vala:1296
msgid "Unsupported Subvolume Layout"
msgstr ""
#: Main.vala:1881
#: Main.vala:1897
msgid "Updated /etc/fstab on target device"
msgstr ""
@ -1273,7 +1288,7 @@ msgstr ""
msgid "Warning"
msgstr ""
#: Main.vala:2082
#: Main.vala:2098
msgid "Warning: Backup device not set! Defaulting to system device"
msgstr ""
@ -1305,7 +1320,7 @@ msgstr ""
msgid "days..."
msgstr ""
#: Main.vala:2563
#: Main.vala:2583
msgid "free"
msgstr ""

View File

@ -17,13 +17,13 @@ long_line_behaviour=1
long_line_column=80
[files]
current_page=5
current_page=1
FILE_NAME_0=1047;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FExcludeMessageWindow.vala;0;4
FILE_NAME_1=59978;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FMain.vala;0;4
FILE_NAME_1=4164;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FMain.vala;0;4
FILE_NAME_2=16543;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FMainWindow.vala;0;4
FILE_NAME_3=40067;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FRestoreWindow.vala;0;4
FILE_NAME_4=17568;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FSettingsWindow.vala;0;4
FILE_NAME_5=20705;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FUtility.vala;0;4
FILE_NAME_5=29607;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FUtility.vala;0;4
FILE_NAME_6=2316;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Finstaller%2Finstall.sh;0;4
FILE_NAME_7=0;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FAboutWindow.vala;0;4
FILE_NAME_8=2333;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Ftimeshift%2Fsrc%2FDonationWindow.vala;0;4