Welcome to the Builder Academy

Question Player File Backup Script & Copyover Addition

More
27 Oct 2025 00:41 - 27 Oct 2025 01:20 #10939 by Salty
Greetings,

I've written a small bash script which generates plrfile and plrobj backups.

Step 1:  navigate to /home/YOUR USERNAME/YOUR MUD DIRECTORY/lib/
Step 2:  mkdir plrback
Step 3:  Create this script in your favorite editor and place it in /home/YOUR USERNAME/YOUR MUD DIRECTORY/lib/

backup.sh
Code:
#!/bin/bash time=`date +"%Y-%m-%d-%H%M%S"` tar -cvzf plrback/plrfiles-$time.tgz ./plrfiles tar -cvzf plrback/plrobjs-$time.tgz ./plrobjs echo done.

Step 4:  Add backup.sh execution to do_copyover or any other function you wish.
Code:
  /*    * Automatically backs up player files and player objects when copyover is ran    * and before any changes are made to the descriptor list.    *   */   int backup = system("/bin/bash /YOUR USERNAME/YOUR MUD DIRECTORY/lib/backup.sh");   if (backup == -1)     mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: backup failed to run.");   else     mudlog(BRF, LVL_IMPL, TRUE, "Backup ran with status: %d", backup);

I placed my system call in do_copyover towards the top:
Code:
/* (c) 1996-97 Erwin S. Andreasen. */ ACMD(do_copyover) {   FILE *fp;   struct descriptor_data *d, *d_next;   char buf[100], buf2[100];   save_all();   House_save_all();   fp = fopen(COPYOVER_FILE, "w");   if (!fp)   {     send_to_char(ch, "Copyover file not writeable, aborted.\n\r");     return;   }   /*    * Automatically backs up player files and player objects when copyover is ran    * and before any changes are made to the descriptor list.    *   */   int backup = system("/bin/bash /YOUR USERNAME/YOUR MUD DIRECTORY/lib/backup.sh");   if (backup == -1)     mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: backup failed to run.");   else     mudlog(BRF, LVL_IMPL, TRUE, "Backup ran with status: %d", backup);   sprintf(buf, "\n\r *** COPYOVER by %s - please remain seated!\n\r", GET_NAME(ch));

With the size of modern hard drives, and the prevalence of SSDs, I don't see any reason to not take incremental backups of player files.

Hope this helps someone.

Salty
Last edit: 27 Oct 2025 01:20 by Salty.
The following user(s) said Thank You: thomas

Please Log in or Create an account to join the conversation.

Time to create page: 0.154 seconds