Added compression && changed directory structure
This commit is contained in:
parent
378c907146
commit
8a0c93172c
@ -3,9 +3,12 @@
|
|||||||
string result = Update.copyEverthingBeforeUpdateToBackupLocation();
|
string result = Update.copyEverthingBeforeUpdateToBackupLocation();
|
||||||
Console.WriteLine(result);
|
Console.WriteLine(result);
|
||||||
|
|
||||||
string result2 = Update.copyEverthingFromBackupLocationToFinalDestination();
|
//string result2 = Update.copyEverthingFromBackupLocationToFinalDestination();
|
||||||
Console.WriteLine(result2);
|
//Console.WriteLine(result2);
|
||||||
|
|
||||||
Console.WriteLine(args);
|
//Console.WriteLine(args.Length);
|
||||||
|
|
||||||
|
bool result3 = Update.zipAllContentInBackupLocation();
|
||||||
|
Console.WriteLine(result3);
|
||||||
}
|
}
|
||||||
}
|
}
|
24
Update.cs
24
Update.cs
@ -1,3 +1,5 @@
|
|||||||
|
using System.IO.Compression;
|
||||||
|
|
||||||
public class Update {
|
public class Update {
|
||||||
public static string getHomePath() {
|
public static string getHomePath() {
|
||||||
string homePath = string.Empty;
|
string homePath = string.Empty;
|
||||||
@ -10,7 +12,7 @@ public class Update {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static string copyEverthingBeforeUpdateToBackupLocation() {
|
public static string copyEverthingBeforeUpdateToBackupLocation() {
|
||||||
string targetPath = getHomePath() + "/backup/";
|
string targetPath = getHomePath() + "/backup/uncompressed/";
|
||||||
|
|
||||||
string[] systemFilesToCopy = {"/etc/fstab", "/etc/makepkg.conf"};
|
string[] systemFilesToCopy = {"/etc/fstab", "/etc/makepkg.conf"};
|
||||||
List<string> filesToCopy = new List<string>(systemFilesToCopy);
|
List<string> filesToCopy = new List<string>(systemFilesToCopy);
|
||||||
@ -67,4 +69,24 @@ public class Update {
|
|||||||
return "You have not configured a backup location!";
|
return "You have not configured a backup location!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool zipAllContentInBackupLocation() {
|
||||||
|
string targetPath = getHomePath() + "/backup/compressed/";
|
||||||
|
Directory.CreateDirectory(targetPath);
|
||||||
|
|
||||||
|
string sourcePath = getHomePath() + "/backup/uncompressed/";
|
||||||
|
string targetZip = getHomePath() + "/backup/compressed/backup.zip";
|
||||||
|
ZipFile.CreateFromDirectory(sourcePath, targetZip);
|
||||||
|
|
||||||
|
string pacmanDatabaseLocation = "/var/lib/pacman/local/";
|
||||||
|
string pacmanDatabaseZip = getHomePath() + "/backup/compressed/pacman_database.zip";
|
||||||
|
ZipFile.CreateFromDirectory(pacmanDatabaseLocation, pacmanDatabaseZip);
|
||||||
|
|
||||||
|
if (File.Exists(targetZip) && File.Exists(pacmanDatabaseZip)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,5 +10,9 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.IO.Compression.ZipFile" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user