Thursday, May 3, 2018

Time Machine "Can't connect to a current Time Machine backup disk"

I decided to start using Time Machine alongside Crashplan to make sure I had a local backup. Plus I'm backing up ~8TB of data on that particular Mac device so having a quick restore option makes a lot of sense.

I purchased a new Thunderbolt 3 drive with plenty of storage and set up Time Machine. Easy enough, right? It only took 2 days to get the initial backup and everything looked like it was working fine. Then I went to try a test restore and that's where I ran into problems. As I entered the Time Machine system to view what was available to restore, an error popped up saying "Can't connect to a current Time Machine backup disk". Nothing would display and I would have to exit. At first I tried a reboot, which didn't work. Then I noticed that the disk displayed a little odd in the Time Machine Preferences so I started over by reselecting my disk and waiting another 2 days for it to redo the initial backup. No luck after that either. That's when I asked my friend Google and found that I should've started there because the answer was very simple...

I had NO permission to access the time machine backup database folder! Why in the world would that be the default setting?! You can confirm that this is your issue too by going into the Time Machine disk and trying to view the contents of the Backups.backupdb folder. If you see a red no-go sign or can't view, you're having the same problem I was.

Luckily it's easy to fix, but you have to use Terminal (Application->Utilities->Terminal) because Finder doesn't seem to work to change permissions on this particular folder. Once you have Terminal open

1. cd /Volumes/TimeMachineDriveName (make sure you put the name of your Time Machine disk here after /Volumes/)
2. sudo chgrp admin Backups.backupdb

The first command just gets you to the Time Machine drive that you need to work with. The second changes the group permissions so that the admin group on your machine can access the folder and it's contents. It will ask you to enter your password after the 2nd command, which is normal when you use sudo to run the command as the root user. Once you've done this you should be able to go back to Time Machine and actually view what has been backed up, and restore files/folders when needed

Wednesday, May 2, 2018

Replace character in variable within batch script

I wanted to rename a file using a batch script so it would replace underscores '_' with hyphens '-'. It was pretty easy

Set img1=this-was_the_original-name-of_the_file
Set newName=%img1:_=-%
echo %newName%

The key to doing it is the :_=- in the second line, which is saying take the text value stored in the variable img1 and make underscores instead equal hyphens. Now, you could make line 2 instead be

Set img1=%img1:_=-%

If you don't need to reference the original value you're storing in img1 later, but for my purposes I was renaming a file so I needed both the original filename and what the new filename should be, so I had to store the new name with the hyphens in a separate variable