mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 11:39:39 +00:00 
			
		
		
		
	Add backup file ignore list.
This commit is contained in:
		@ -14,8 +14,10 @@ import java.io.BufferedOutputStream
 | 
				
			|||||||
import java.io.FileInputStream
 | 
					import java.io.FileInputStream
 | 
				
			||||||
import java.io.FileOutputStream
 | 
					import java.io.FileOutputStream
 | 
				
			||||||
import java.io.IOException
 | 
					import java.io.IOException
 | 
				
			||||||
 | 
					import java.nio.file.FileSystems
 | 
				
			||||||
import java.nio.file.Files
 | 
					import java.nio.file.Files
 | 
				
			||||||
import java.nio.file.Path
 | 
					import java.nio.file.Path
 | 
				
			||||||
 | 
					import java.nio.file.Paths
 | 
				
			||||||
import java.time.Instant
 | 
					import java.time.Instant
 | 
				
			||||||
import java.util.concurrent.atomic.AtomicBoolean
 | 
					import java.util.concurrent.atomic.AtomicBoolean
 | 
				
			||||||
import java.util.zip.ZipEntry
 | 
					import java.util.zip.ZipEntry
 | 
				
			||||||
@ -119,8 +121,10 @@ class BackupCommand(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private fun addDirectoryToZip(zipStream: ZipOutputStream, directoryPath: Path) {
 | 
					  private fun addDirectoryToZip(zipStream: ZipOutputStream, directoryPath: Path) {
 | 
				
			||||||
 | 
					    val matchers = config.ignore.map { FileSystems.getDefault().getPathMatcher("glob:$it") }
 | 
				
			||||||
    val paths = Files.walk(directoryPath)
 | 
					    val paths = Files.walk(directoryPath)
 | 
				
			||||||
      .filter { path: Path? -> Files.isRegularFile(path) }
 | 
					      .filter { path: Path -> Files.isRegularFile(path) }
 | 
				
			||||||
 | 
					      .filter { path -> !matchers.any { it.matches(Paths.get(path.normalize().toString())) } }
 | 
				
			||||||
      .toList()
 | 
					      .toList()
 | 
				
			||||||
    val buffer = ByteArray(1024)
 | 
					    val buffer = ByteArray(1024)
 | 
				
			||||||
    val backupsPath = backupsPath.toRealPath()
 | 
					    val backupsPath = backupsPath.toRealPath()
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,9 @@ import kotlinx.serialization.Serializable
 | 
				
			|||||||
@Serializable
 | 
					@Serializable
 | 
				
			||||||
data class BackupConfig(
 | 
					data class BackupConfig(
 | 
				
			||||||
  val schedule: ScheduleConfig = ScheduleConfig(),
 | 
					  val schedule: ScheduleConfig = ScheduleConfig(),
 | 
				
			||||||
 | 
					  val ignore: List<String> = listOf(
 | 
				
			||||||
 | 
					    "plugins/dynmap/web/**"
 | 
				
			||||||
 | 
					  ),
 | 
				
			||||||
  val s3: S3Config = S3Config(),
 | 
					  val s3: S3Config = S3Config(),
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,11 @@ schedule:
 | 
				
			|||||||
  # "0 3 ? * SUN" -> every Sunday at 3 AM
 | 
					  # "0 3 ? * SUN" -> every Sunday at 3 AM
 | 
				
			||||||
  cron: ""
 | 
					  cron: ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# List of file patterns to ignore and ignore in the backup.
 | 
				
			||||||
 | 
					ignore:
 | 
				
			||||||
 | 
					  # Dynmap web output.
 | 
				
			||||||
 | 
					  - "plugins/dynmap/web/**"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configuration of S3 service to upload back-ups to.
 | 
					# Configuration of S3 service to upload back-ups to.
 | 
				
			||||||
s3:
 | 
					s3:
 | 
				
			||||||
  # The access key ID from your S3-compliant storage provider.
 | 
					  # The access key ID from your S3-compliant storage provider.
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user